当前位置: 首页>>代码示例>>C#>>正文


C# Wall.MergeWithOtherType方法代码示例

本文整理汇总了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);
        }
开发者ID:bennygrub,项目名称:msl,代码行数:76,代码来源:WallController.cs


注:本文中的Wall.MergeWithOtherType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。