public IHttpActionResult SavePaymentMethod(ArtistPagePaymentModel Model) { if (!ModelState.IsValid) return Response(new { Success = false, Message = "Invalid data submitted" }); var artistPage = _artistPageService.Get(Model.ArtistPageId); if (CanEdit(artistPage)) { var paymentMethod = _artistPagePaymentService.GetPaymentMethod(Model.ArtistPageId); if (paymentMethod == null) { paymentMethod = new ArtistPagePayment(); } //set the new values paymentMethod.AccountNumber = Model.AccountNumber; paymentMethod.Address = Model.Address; paymentMethod.ArtistPageId = Model.ArtistPageId; paymentMethod.BankName = Model.BankName; paymentMethod.City = Model.City; paymentMethod.Country = Model.Country; paymentMethod.PostalCode = Model.PostalCode; paymentMethod.PayableTo = Model.PayableTo; paymentMethod.PaymentType = (ArtistPagePayment.PagePaymentType)Model.PaymentTypeId; paymentMethod.PaypalEmail = Model.PaypalEmail; paymentMethod.RoutingNumber = Model.RoutingNumber; if (paymentMethod.Id == 0) _artistPagePaymentService.InsertPaymentMethod(paymentMethod); else _artistPagePaymentService.UpdatePaymentMethod(paymentMethod); return Response(new { Success = true }); } else { return Response(new { Success = false, Message = "Unauthorized" }); } }
public IHttpActionResult GetPaymentMethod(int artistPageId) { var artistPage = _artistPageService.Get(artistPageId); if (CanDelete(artistPage)) { //the user can access payment method. let's fetch it. var paymentMethod = _artistPagePaymentService.GetPaymentMethod(artistPageId); if (paymentMethod != null) { var model = new ArtistPagePaymentModel() { AccountNumber = paymentMethod.AccountNumber, Address = paymentMethod.Address, BankName = paymentMethod.BankName, City = paymentMethod.City, Country = paymentMethod.Country, PostalCode = paymentMethod.PostalCode, PayableTo = paymentMethod.PayableTo, PaymentTypeId = (int)paymentMethod.PaymentType, PaypalEmail = paymentMethod.PaypalEmail, RoutingNumber = paymentMethod.RoutingNumber, ArtistPageId = paymentMethod.ArtistPageId, Id = paymentMethod.Id }; return Response(new { Success = true, PaymentMethod = model }); } else { var model = new ArtistPagePaymentModel() { ArtistPageId = artistPageId, PaymentTypeId = (int)ArtistPagePayment.PagePaymentType.Paypal }; return Response(new { Success = true, PaymentMethod = model }); } } else { return Response(new { Success = false, Message = "Unauthorized" }); } }