public bool UpdatePaymentInformation(SavedPaymentInformationEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.SavedPaymentInformations.Single(e => e.OwnerId == model.OwnerId && e.OwnerId == _userId); entity.CardNumber = model.CardNumber; entity.SavedPaymentInformationName = model.SavedPaymentInformationName; entity.ExpirationDate = model.ExpirationDate; entity.CVV = model.CVV; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(SavedPaymentInformationEdit sr) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePayment(); if (!service.UpdatePaymentInformation(sr)) { return(InternalServerError()); } return(Ok()); }