/// <summary> /// Get CustomerType by id /// </summary> /// <param name="id">ID of CustomerType</param> /// <returns></returns> public ApiResponseViewModel GetById(int id) { var result = new CustomerTypeViewModel(); var response = new ApiResponseViewModel { Code = CommonConstants.ApiResponseSuccessCode, Message = null, Result = null }; try { var exists = _customerTypeRepository.CheckContains(m => m.ID == id); if (exists) { var tempResult = _customerTypeRepository.GetSingleById(id); result.ID = tempResult.ID; result.CustomerTypeName = tempResult.CustomerTypeName; result.IsActive = tempResult.IsActive ?? false; response.Result = result; } else { response.Code = CommonConstants.ApiResponseNotFoundCode; response.Message = CommonConstants.NotFoundMessage; } } catch (Exception ex) { response.Code = CommonConstants.ApiResponseExceptionCode; response.Message = CommonConstants.ErrorMessage + " " + ex.Message; } return(response); }
/// <summary> /// Update CustomerType /// </summary> /// <param name="obj">New CustomerType</param> /// <returns></returns> public ApiResponseViewModel Update(CustomerType obj) { var result = new CustomerTypeViewModel(); var response = new ApiResponseViewModel { Code = CommonConstants.ApiResponseSuccessCode, Message = null, Result = null }; try { var exists = _customerTypeRepository.CheckContains(m => m.ID == obj.ID); if (exists) { _customerTypeRepository.Update(obj); _unitOfWork.Commit(); response.Message = CommonConstants.SaveSuccess; } else { response.Code = CommonConstants.ApiResponseNotFoundCode; response.Message = CommonConstants.NotFoundMessage; } } catch (Exception ex) { response.Code = CommonConstants.ApiResponseExceptionCode; response.Message = CommonConstants.ErrorMessage + " " + ex.Message; } return(response); }
private void InitTareValues() { var caseTypes = _manageCaseService.GetTypes().ToList().Select(x => new CaseTypeViewModel() { Name = x.Name, Id = x.Id }).ToList(); ; ViewBag.CaseTypes = caseTypes; var customerTypes = _customerTypeRepository.GetAll().ToList().Select(x => new CustomerTypeViewModel() { Id = x.Id, Name = x.Name }).ToList(); var defaultCustomer = new CustomerTypeViewModel() { Id = 0, Name = "Both" }; customerTypes.Add(defaultCustomer); Session["CustomerTypes"] = customerTypes; ViewBag.DefaultCustomerType = defaultCustomer; ViewBag.DefaultCaseType = caseTypes.FirstOrDefault(); }
public ActionResult Save(CustomerType customerType) { if (!ModelState.IsValid) { var viewModel = new CustomerTypeViewModel { Customertype = customerType, }; return(View("CustomerTypeForm", viewModel)); } if (customerType.Id == 0) { _context.CustomerTypes.Add(customerType); } else { var customerTypeInDb = _context.CustomerTypes.Single(m => m.Id == customerType.Id); customerTypeInDb.Type = customerType.Type; customerTypeInDb.SignUpFee = customerType.SignUpFee; customerTypeInDb.DurationInMonths = customerType.DurationInMonths; customerTypeInDb.DiscountRate = customerType.DiscountRate; } _context.SaveChanges(); return(RedirectToAction("Index", "CustomerType")); }
public IActionResult Update([FromBody] CrudViewModel <CustomerTypeViewModel> payload) { CustomerTypeViewModel value = payload.value; var result = _functionalService .Update <CustomerTypeViewModel, CustomerType>(value, Convert.ToInt32(value.CustomerTypeId)); return(Ok()); }
public ActionResult CustomerTypeForm() { var viewModel = new CustomerTypeViewModel { Customertype = new CustomerType(), }; return(View("CustomerTypeForm", viewModel)); }
public CustomerTypes() : base() { InitializeComponent(); this.toolstripChild = this.toolStripChildForm; this.fastListIndex = this.fastCustomerTypeIndex; this.customerTypeAPIs = new CustomerTypeAPIs(CommonNinject.Kernel.Get <ICustomerTypeAPIRepository>()); this.customerTypeViewModel = CommonNinject.Kernel.Get <CustomerTypeViewModel>(); this.customerTypeViewModel.PropertyChanged += new PropertyChangedEventHandler(ModelDTO_PropertyChanged); this.baseDTO = this.customerTypeViewModel; }
public ActionResult Edit(int id) { var customertype = _context.CustomerTypes.SingleOrDefault(m => m.Id == id); if (customertype == null) { return(HttpNotFound()); } var viewModel = new CustomerTypeViewModel { Customertype = customertype, }; return(View("CustomerTypeForm", viewModel)); }