public IHttpActionResult Put([FromUri] int customerId, [FromBody] Saving_Account saving) { if (ModelState.IsValid) { using (BankDbEntities db = new BankDbEntities()) { var id = db.Saving_Account.FirstOrDefault(s => s.CustomerId == customerId); if (id == null) { return(NotFound()); } else { id.AccountNo = saving.AccountNo; id.BranchCode = saving.BranchCode; id.CurrentBalance = saving.CurrentBalance; id.EmailId = saving.EmailId; id.FirstName = saving.FirstName; id.LastName = saving.LastName; id.PhoneNo = saving.PhoneNo; db.SaveChanges(); return(Ok("Sucessfully Altered")); } } } else { return(BadRequest("Not a valid Model")); } }
public async Task <IHttpActionResult> PostSavingData([FromBody] Saving_Account saving) { if (ModelState.IsValid) { using (BankDbEntities Db = new BankDbEntities()) { Db.Saving_Account.Add(saving); var x = await Db.SaveChangesAsync(); return(Ok("Added account " + x)); } } else { return(BadRequest("Model is not valid")); } }