public static void GetDiet(DietEditVM vm, ref Diet diet) { if (diet == null) { diet = new Diet(); } if (vm != null) { diet.HeaderBG = vm.HeaderBG; diet.HeaderEN = vm.HeaderEN; diet.TextBG = vm.TextBG; diet.TextEN = vm.TextEN; diet.IsImportant = vm.IsImportant; } }
public virtual ActionResult Edit(Guid id) { var diet = unitOfWork.DietRepository.GetByID(id); if (diet == null) diet = new Diet() { DietId = id }; var vm = DietMapper.GetVM(diet); vm.AvailableHashtags = unitOfWork.HashtagRepository.Get().OrderBy(e => e.TextBG).Select(e => new SelectListItem() { Value = e.HashtagId.ToString(), Text = e.TextBG }); return View(vm); }
public static DietEditVM GetVM(Diet diet) { var vm = new DietEditVM(); if (diet == null) diet = new Diet() { DietId = Guid.NewGuid() }; vm.DietId = diet.DietId; vm.FileName = diet.FileName; vm.HeaderBG = diet.HeaderBG; vm.HeaderEN = diet.HeaderEN; vm.TextBG = diet.TextBG; vm.TextEN = diet.TextEN; vm.IsImportant = diet.IsImportant; vm.HashtagIds = diet.DietsHashtagsXRefs.Select(e => e.HashtagId).ToList(); return vm; }