public ActionResult CreateEdit(long Id = 0) { NeNews item = new NeNews(); ViewBag.CategoryList = _neCategoryService.LoadAll(true); if (Id > 0) { item = _neNewsService.Get(Id); } else { NeNewsDetails _itemDetails = new NeNewsDetails(); _itemDetails.Language = GlobalContext.WebSite.Language; item.Details.Add(_itemDetails); } if (GlobalContext.WebSite.IsMultiLangual) { foreach (var lang in SupportedCultures.Cultures) { var count = item.Details.Where(x => x.Language == lang.TwoLetterISOLanguageName).Count(); if (count <= 0) { NeNewsDetails _itemDetails = new NeNewsDetails(); _itemDetails.Language = lang.TwoLetterISOLanguageName; item.Details.Add(_itemDetails); } } } return(View(item)); }
private void CopyNewData(NeNews oldEntity, NeNews entity) { oldEntity.ModificationDate = entity.ModificationDate; oldEntity.ModifyBy = entity.ModifyBy; oldEntity.Name = entity.Name; oldEntity.Status = entity.Status; oldEntity.HasDateRange = entity.HasDateRange; oldEntity.PublishDate = entity.PublishDate; oldEntity.ExpireDate = entity.ExpireDate; oldEntity.Order = entity.Order; oldEntity.CategoryList = entity.CategoryList; var currentDateTime = DateTime.Now; foreach (var item in entity.Details) { var isNew = false; var temp = oldEntity.Details.Where(x => x.Language == item.Language).FirstOrDefault(); if (temp == null) { isNew = true; temp = new NeNewsDetails(); temp.Language = item.Language; } temp.Metadata = item.Metadata; temp.Name = item.Name; temp.Content = item.Content; temp.Excerpt = item.Excerpt; if (isNew) { oldEntity.Details.Add(temp); } } }