public IActionResult DeleteWorkType(int id, WorkTypeViewModel model) { WorkType workType = _repository.GetWorkTypeById(id); _repository.DeleteEntity(workType); _repository.SaveAll(); return(RedirectToAction("AllWorkType")); }
public IActionResult DeleteWorkType(int id) { WorkTypeViewModel model = new WorkTypeViewModel(); var workType = _repository.GetWorkTypeById(id); model = _mapper.Map <WorkType, WorkTypeViewModel>(workType); return(PartialView("~/Areas/Transit/Views/Transit/DeleteWorkType.cshtml", model)); }
private void WorkControl_Tapped(object sender, TappedRoutedEventArgs e) { var cntrl = sender as FrameworkElement; if (cntrl == null) { return; } _selectedVM = cntrl.DataContext as WorkTypeViewModel; if (_selectedVM == null) { return; } _selectedVM.ShowDetail(); }
public int CreateOrUpdate(WorkTypeViewModel item) { var data = (WorkType)null; if (item.Id > 0) { data = Repository.FirstOrDefault(x => x.Id == item.Id); } data = ToDomain(item, data); Repository.Store(data); Repository.SaveChanges(); return(data.Id); }
public ActionResult ManageType(WorkTypeViewModel workType) { // Check Model. if (ModelState.IsValid) { var update = Mapper.Map <IWorkTypeDto>(workType); workType = Mapper.Map <WorkTypeViewModel>(Factory.Save(update)); } else { workType = Mapper.Map <WorkTypeViewModel>(Factory.GetById <IWorkTypeDto>(workType.WorkTypeId.ToString())); } ViewBag.GroupTypeSelection = GroupTypeSelection(workType); return(PartialView("_WorkTypeManage", workType)); }
private List <SelectListItem> GroupTypeSelection(WorkTypeViewModel type) { // Load Groups. var groups = Factory.GetDisplayList <IWorkTypeGroupDto>().OrderBy(g => g.Value) .Select(g => new SelectListItem { Value = g.Key, Text = g.Value }).ToList(); // Check Type. if (type?.WorkTypeGroupId > 0 && groups.All(g => g.Value != type.WorkTypeGroupId.ToString())) { // Add If Not Found. groups.Add(new SelectListItem { Value = type.WorkTypeGroupId.ToString(), Text = $@"{ type.WorkTypeGroupName } (Disabled)" }); } return(groups); }
public IActionResult AddEditWorkType(int?id) { WorkTypeViewModel model = new WorkTypeViewModel(); try { var workType = _repository.GetWorkTypeById(id); if (id.HasValue) { model = _mapper.Map <WorkType, WorkTypeViewModel>(workType); } // ViewBag.ProcessName = _repository.GetAllControlTools(); return(PartialView("~/Areas/Transit/Views/Transit/AddEditWorkType.cshtml", model)); } catch (Exception ex) { return(BadRequest("Failed to get orders")); } }
public IActionResult AddEditWorkType(int?id, WorkTypeViewModel model) { if (ModelState.IsValid) { bool isNew = !id.HasValue; var newWorkType = _mapper.Map <WorkTypeViewModel, WorkType>(model); if (isNew) { _repository.AddEntity(newWorkType); _repository.SaveAll(); } else { WorkType oldWorkType = _repository.GetWorkTypeById(id); oldWorkType.Name = newWorkType.Name; _repository.SaveAll(); } } return(RedirectToAction("AllWorkType")); }
private void ContentControl_Loaded(object sender, RoutedEventArgs e) { _vm = DataContext as WorkTypeViewModel; }