public void SelectValue(object sender, EventArgs e) { int[] rows = ServiceTypeView.GetSelectedRows(); SelectedValue = Convert.ToInt32(ServiceTypeView.GetRowCellValue(rows[0], "Id")); SelectedCode = ServiceTypeView.GetRowCellValue(rows[0], "Name").ToString(); SelectedText = ServiceTypeView.GetRowCellValue(rows[0], "Name").ToString(); Hide(); }
public ActionResult Edit(int?serviceTypePK) { if (serviceTypePK != null) { IServiceTypesRepository serviceTypesRepository = new ServiceTypesRepository(db); ServiceType serviceType = serviceTypesRepository.GetServiceTypeByPK((int)serviceTypePK); ServiceTypeView serviceTypeView = new ServiceTypeView(); serviceTypeView.ConvertFrom(serviceType, serviceTypeView); return(View(serviceTypeView)); } else { return(RedirectToAction("Index", "ServiceType")); } }
public ActionResult Edit(ServiceTypeView serviceTypeModel) { if (ModelState.IsValid) { IServiceTypesRepository serviceTypesRepository = new ServiceTypesRepository(db); ServiceType serviceType = serviceTypesRepository.GetServiceTypeByPK((int)serviceTypeModel.ServiceTypePK); serviceTypeModel.ConvertTo(serviceTypeModel, serviceType); serviceTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", serviceType.ServiceTypePK); return(RedirectToAction("Index", "ServiceType")); } else { return(View(serviceTypeModel)); } }
public ActionResult Add(ServiceTypeView serviceTypeView) { if (ModelState.IsValid) { IServiceTypesRepository serviceTypesRepository = new ServiceTypesRepository(db); ServiceType serviceType = new ServiceType(); serviceTypeView.ConvertTo(serviceTypeView, serviceType); serviceTypesRepository.Add(serviceType); serviceTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", serviceType.ServiceTypePK); return(RedirectToAction("Index", "ServiceType")); } else { return(View(serviceTypeView)); } }