本文整理汇总了C#中Wall.MergeWithOtherType方法的典型用法代码示例。如果您正苦于以下问题:C# Wall.MergeWithOtherType方法的具体用法?C# Wall.MergeWithOtherType怎么用?C# Wall.MergeWithOtherType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wall
的用法示例。
在下文中一共展示了Wall.MergeWithOtherType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(WallModel model)
{
if (ModelState.IsValid)
{
using (var db = new MySelfieEntities())
{
try
{
Wall wall;
wall = new Wall();
wall.MergeWithOtherType(model);
if (model.LogoPath.IsEmptyOrNull()) wall.LogoPath = "";
if (model.FrameTopColor.IsEmptyOrNull()) wall.FrameTopColor = "#DDDDDD";
if (model.FrameBottomColor.IsEmptyOrNull()) wall.FrameBottomColor = "#FFFFFF";
if (model.RetweetMessage.IsEmptyOrNull()) wall.RetweetMessage = "";
if (model.CaptionText.IsEmptyOrNull()) wall.CaptionText = "";
if (model.DescriptionText.IsEmptyOrNull()) wall.DescriptionText = "";
if (model.RightText.IsEmptyOrNull()) wall.RightText = "";
if (model.Title.IsEmptyOrNull()) wall.Title = "";
if (model.LogoImageFile.HasFile())
{
wall.LogoImage = model.LogoImageFile.getFileBytes(); // extracts bytes from posted file
wall.LogoImageType = model.LogoImageFile.getFileType(); // extracts type from posted file
}
//Johnm - some mismatches on column naming, thus mergeWithOtherType not working
wall.PostingAccount_InstagramToken = model.Post_InstagramToken;
wall.IsActive = false;
wall.CreatedAt = DateTime.UtcNow;
wall.Status = "new";
db.Walls.Add(wall);
wall.Name = model.Name;
db.SaveChanges();
}
catch (DbEntityValidationException ex)
{
// Retrieve the error messages as a list of strings.
var errorMessages = ex.EntityValidationErrors
.SelectMany(x => x.ValidationErrors)
.Select(x => x.ErrorMessage);
// Join the list to a single string.
var fullErrorMessage = string.Join("; ", errorMessages);
// Combine the original exception message with the new one.
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
Logger.Log(exceptionMessage, "error", User.Identity.Name, "POST /Wall/Create");
ModelState.AddModelError("ex", ex);
return View(model);
}
catch (Exception ex)
{
Logger.Log(ex.ToString(), "error", User.Identity.Name, "POST /Wall/Create");
ModelState.AddModelError("ex", ex);
return View(model);
}
}
return RedirectToAction("Index", "Wall");
}
return View(model);
}