public string UpdatePaymentMethod(PaymentMethodVM paymentMethod) { string paymentMethodId = string.Empty; SqlParameter[] parameters = { new SqlParameter { ParameterName = "@Id", Value = paymentMethod.Id }, new SqlParameter { ParameterName = "@Code", Value = paymentMethod.Code }, new SqlParameter { ParameterName = "@Name", Value = paymentMethod.Name }, new SqlParameter { ParameterName = "@Description", Value = paymentMethod.Description }, new SqlParameter { ParameterName = "@IsCreditCardPay", Value = paymentMethod.IsCreditCardPay }, new SqlParameter { ParameterName = "@IsActive", Value = paymentMethod.IsActive }, new SqlParameter { ParameterName = "@UpdatedBy", Value = paymentMethod.UpdatedBy } }; paymentMethodId = Convert.ToString(DALHelper.ExecuteScalar("UpdatePaymentMethod", parameters)); return(paymentMethodId); }
public static void SeedData(IServiceProvider serviceProvider) { var clientService = serviceProvider.GetRequiredService <IClientApplicationService>(); if (clientService.GetAll().Count == 0) { AddressVM addressVM = new AddressVM(); addressVM.CEP = "13276-130"; addressVM.Estate = "SP"; addressVM.Street = "Av. Onze de Agosto"; addressVM.Number = "623"; addressVM.City = "Valinhos"; addressVM.District = "Centro"; addressVM.Reference = ""; var addressService = serviceProvider.GetRequiredService <IAddressApplicationService>(); addressVM = addressService.Add(addressVM); for (int i = 0; i < 50; i++) { ClientVM client = new ClientVM(); client.Name = $"Cliente - {i}"; client.Contact = $"Contanto - {i}"; client.SaleIsFinished = false; client.Phone = "19-99999-9999"; client.Address = addressVM; clientService.Add(client); } var productService = serviceProvider.GetRequiredService <IProductApplicationService>(); var routeService = serviceProvider.GetRequiredService <IRouteApplicationService>(); for (int i = 0; i < 10; i++) { RouteVM route = new RouteVM(); route.Name = $"Rota - {i}"; route.KmDistance = 100 + 1; route.Truck = $"Costallation - {i}"; route.HasOpenDelivery = false; routeService.Add(route); } var paymentService = serviceProvider.GetRequiredService <IPaymentApplicationService>(); PaymentMethodVM paymentMethodVM = new PaymentMethodVM(); paymentMethodVM.MethodName = "Check"; paymentMethodVM.Descrition = "Payment with check"; paymentService.AddPaymentMethod(paymentMethodVM); paymentMethodVM.MethodName = "Money"; paymentMethodVM.Descrition = "Payment with Money"; paymentService.AddPaymentMethod(paymentMethodVM); paymentMethodVM.MethodName = "Bank bill"; paymentMethodVM.Descrition = "Payment with Bank bill"; paymentService.AddPaymentMethod(paymentMethodVM); paymentMethodVM.MethodName = "Credit"; paymentMethodVM.Descrition = "Payment with Credit"; paymentService.AddPaymentMethod(paymentMethodVM); } }
public ActionResult Edit(Guid id) { var paymentMethod = paymentMethodRepository.GetPaymentMethodById(id); PaymentMethodVM model = new PaymentMethodVM(); if (paymentMethod != null && paymentMethod.Count > 0) { model = paymentMethod[0]; return(View(model)); } return(RedirectToAction("List")); }
public void AddPaymentMethod(PaymentMethodVM paymentMethodVM) { try { var paymentMethod = _mapper.Map <PaymentMethod>(paymentMethodVM); _unitOfWork.Repository <PaymentMethod>().Add(paymentMethod); _unitOfWork.CommitSync(); } catch (CustomException exc) { throw exc; } catch (Exception ex) { throw CustomException.Create <PaymentApplicationService>("Unexpected error fetching add PaymentMethod", nameof(this.AddPaymentMethod), ex); } }
public ActionResult Edit(PaymentMethodVM model) { try { string paymentMethodId = string.Empty; model.UpdatedBy = LogInManager.LoggedInUserId; model.Code = !string.IsNullOrWhiteSpace(model.Code) ? model.Code.ToUpper() : model.Code; paymentMethodId = paymentMethodRepository.UpdatePaymentMethod(model); if (!string.IsNullOrWhiteSpace(paymentMethodId)) { return(Json(new { IsSuccess = true, data = new { PaymentMethodId = paymentMethodId } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Payment Method details not updated successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Edit"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }