public void ContractController_PutContract_ShouldReturnOk() { var contract = new ContractEdit { ContractId = 1 }; var result = _controller.Put(contract); Assert.AreEqual(1, _mockService.CallCount); Assert.IsInstanceOfType(result, typeof(OkResult)); }
public IHttpActionResult Put(ContractEdit contract) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_contractService.UpdateContracts(contract)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateContracts(ContractEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Contracts .Single(e => e.ContractId == model.ContractId && e.OwnerId == _userid); entity.ContractId = model.ContractId; entity.Dev.DevId = model.DevId; entity.DevTeamId = model.DevTeamId; return(ctx.SaveChanges() == 1); } }
public bool UpdateContract(ContractEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Contracts .Single(e => e.ContractID == model.ContractID && e.OwnerID == _userId); entity.ContractID = model.ContractID; entity.ContractName = model.Name; return(ctx.SaveChanges() == 1); } }
public bool UpdateContract(ContractEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Contracts .Single(e => e.ContractId == model.ContractId); entity.StartDate = model.StartDate; entity.EndDate = model.EndDate; entity.DeveloperId = model.DeveloperId; entity.TeamId = model.TeamId; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateContractService(); var detail = service.GetContractById(id); var model = new ContractEdit { ContractId = detail.ContractId, ClientName = detail.ClientName, MowerName = detail.MowerName, ClientCity = detail.ClientCity, MowerService = detail.MowerService, MowerRate = detail.MowerRate, }; return(View(model)); }
public bool UpdateContract(ContractEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Contracts .Single(e => e.ContractId == model.ContractId && e.OwnerId == _userId); entity.Client.ClientName = model.ClientName; entity.Mower.MowerName = model.MowerName; entity.Client.ClientCity = model.ClientCity; entity.Mower.MowerService = model.MowerService; entity.Mower.MowerRate = model.MowerRate; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, ContractEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ContractId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateContractService(); if (service.UpdateContract(model)) { TempData["SaveResult"] = "Your note was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your note could not be updated."); return(View(model)); }
public bool UpdateContract(ContractEdit model) { return(ReturnValue); }
public bool UpdateContracts(ContractEdit model) { CallCount++; return(ReturnValue); }