public IHttpActionResult PutAvailableFunds(AvailableFundsViewModel funds) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } using (db) { var existingFunds = db.AvailableFunds.Where(u => u.AvailableFundsID == funds.AvailableFundsID) .FirstOrDefault <AvailableFunds>(); if (existingFunds != null) { existingFunds.AvailableMoney = funds.AvailableMoney; db.SaveChanges(); } else { return(NotFound()); } } return(Ok()); }
public IHttpActionResult PostAvailableFunds(AvailableFundsViewModel funds) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } using (db) { db.AvailableFunds.Add(new AvailableFunds() { AvailableFundsID = funds.AvailableFundsID, AvailableMoney = funds.AvailableMoney }); db.SaveChanges(); } return(Ok()); }