public ResModel AddPaymentType(PaymentTypeDto paymentTypeDto, UserDto operationUser) { using (var db = new ModelContext()) { var paymentType = new PaymentType() { Id = Guid.NewGuid(), Name = paymentTypeDto.Name, IconUrl = "../../Content/img/payment/default-pay.png", SelectedIconUrl = "../../Content/img/payment/default-selected-pay.png", Description = paymentTypeDto.Description }; try { db.PaymentType.Add(paymentType); db.SaveChanges(); } catch (Exception e) { return(new ResModel() { Msg = "添加付款方式失败", Success = false }); } return(new ResModel() { Msg = "添加付款方式成功", Success = true }); } }
public ResModel UpdatePaymentType(PaymentTypeDto paymentTypeDto, UserDto operationUser) { using (var db = new ModelContext()) { var paymentType = db.PaymentType.FirstOrDefault(i => i.Id == paymentTypeDto.Id); if (paymentType == null) { return(new ResModel() { Msg = "更新付款方式失败,未找到该付款方式", Success = false }); } try { paymentType.Name = paymentTypeDto.Name; paymentType.Description = paymentTypeDto.Description; db.SaveChanges(); } catch (Exception e) { return(new ResModel() { Msg = "更新付款方式失败", Success = false }); } return(new ResModel() { Msg = "更新付款方式成功", Success = true }); } }
public async Task Update(PaymentTypeDto productDto) { var product = ObjectMapper.Map <Models.PaymentType>(productDto); await _repository.UpdateAsync(product); return; }
public IActionResult Post([FromBody] PaymentTypeDto paymentTypeDto) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var paymentType = Mapper.Map <PaymentType>(paymentTypeDto); if (_paymentTypeRepository.PaymentTypeExists(paymentType)) { return(StatusCode(500, "PaymentType already exists.")); } var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var profile = _accountRepository.GetUserProfile(userId); var createdPaymentType = _paymentTypeRepository.CreatePaymentType(paymentType, profile.UserProfileId); if (createdPaymentType == null) { return(StatusCode(500, "A problem happened while handling your request.")); } var createdPaymentTypeToReturn = Mapper.Map <PaymentTypeDto>(createdPaymentType); return(Created(createdPaymentTypeToReturn)); } catch (Exception ex) { _logger.LogError($"Failed in Post /PaymentTypes: {ex}"); return(StatusCode(500, "A problem happened while handling your request.")); } }
public async Task <IActionResult> Create(PaymentTypeDto paymentTypeDto) { if (ModelState.IsValid) { await paymentTypeService.Create(paymentTypeDto); return(RedirectToAction("Index")); } return(View(paymentTypeDto)); }
public IActionResult Post([FromBody] PaymentTypeDto model) { if (ModelState.IsValid) { var paymentType = _iMapper.Map <PaymentType>(model); var added = _iPaymentTypeManager.Add(paymentType); if (added) { return(Ok(paymentType)); } return(BadRequest(new { error = "Failed to Add Payment Type!!" })); } return(BadRequest(new { error = "Not Valid Payment Type!!" })); }
public async Task Create(PaymentTypeDto paymentTypeDto) { if (paymentTypeDto.IsActiv == true) { SetAllNonActive(); } var paymentType = new PaymentType() { Name = paymentTypeDto.Name, Description = paymentTypeDto.Description, IsActiv = paymentTypeDto.IsActiv, RequireBankAccount = paymentTypeDto.RequiredBankAccount, }; await paymentTypeRepository.AddAsync(paymentType); await paymentTypeRepository.SaveChangesAsync(); }
public async Task Edit(PaymentTypeDto paymentTypeDto) { var paymentType = paymentTypeRepository.All().Where(e => e.Id == paymentTypeDto.Id).FirstOrDefault(); if (paymentTypeDto.Id != 0 && paymentType != null) { if (paymentTypeDto.IsActiv == true) { SetAllNonActive(); } paymentType.Name = paymentTypeDto.Name; paymentType.Description = paymentTypeDto.Description; paymentType.IsActiv = paymentTypeDto.IsActiv; paymentType.RequireBankAccount = paymentTypeDto.RequiredBankAccount; paymentTypeRepository.Update(paymentType); await paymentTypeRepository.SaveChangesAsync(); } }
public IActionResult Put(int id, [FromBody] PaymentTypeDto model) { var retrivePaymentType = _iPaymentTypeManager.GetById(id); if (retrivePaymentType == null) { return(BadRequest(new { error = "Can Not found Payment Type!!" })); } var paymentType = _iMapper.Map <PaymentType>(model); retrivePaymentType.Name = paymentType.Name; retrivePaymentType.Description = paymentType.Description; retrivePaymentType.IsDelete = retrivePaymentType.IsDelete; bool isUpdate = _iPaymentTypeManager.Update(retrivePaymentType); if (isUpdate) { return(Ok(retrivePaymentType)); } return(BadRequest(new { error = "Failed to Update Data!!" })); }
public OrderDto(OrderCreateModel orderCreateModel, CustomerDto customer, CompanyDto company, AdressDTO address, PaymentTypeDto paymentType) { //Order section Number = orderCreateModel.Number; //Company section CompanyBTW = company.BTW; CompanyCity = company.City; CompanyCountryName = company.Country.Name; CompanyHouseNumber = company.HouseNumber; CompanyIBAN = company.IBAN; CompanyKVK = company.KVK; CompanyLogo = company.Logo; CompanyName = company.Name; CompanyPhoneNumber = company.PhoneNumber; CompanyId = company.Id; CompanyPostalCode = company.PostalCode; CompanyProvinceName = company.Province.Name; CompanyStreetAddress = company.StreetAddress; //Customer section CustomerCity = address.City; CustomerCompanyEmail = customer.CompanyEmail; CustomerCompanyName = customer.CompanyName; CustomerCompanyPhonenumber = company.PhoneNumber; CustomerCountryName = address.Country.Name; CustomerHouseNumber = address.HouseNumber; CustomerPhoneNumber = address.PhoneNumber; CustomerPostalCode = address.PostalCode; CustomerProvinceName = address.Province.Name; CustomerStreetAddress = address.StreetAddress; CustomerTaxable = address.Taxable; CustomerId = customer.Id; CustomerAddressId = orderCreateModel.AddressId; //Payment type section PaymentTypeName = paymentType.TypeName; PaymentTypeId = paymentType.Id; }
public ResModel UpdatePaymentType(PaymentTypeDto paymentTypeDto, UserDto operationUser) { return(_paymentTypeRepository.UpdatePaymentType(paymentTypeDto, operationUser)); }
public ActionResult Update(PaymentTypeDto paymentTypeDto) { var currentUser = Session["LogUser"] as UserDto; return(Json(_paymentTypeService.UpdatePaymentType(paymentTypeDto, currentUser))); }