public IActionResult EditWarrantyModal(Models.Warranty.EditWarranty model) { if (ModelState.IsValid) { WarrantyDto dto = new WarrantyDto { WarrantyId = model.WarrantyId, EndDate = model.EndDate.ToUniversalTime(), StartDate = model.StartDate.ToUniversalTime(), TeamId = model.TeamId, UserId = model.UserId, WarrantyName = model.WarrantyName, WarrentyDescription = model.WarrentyDescription }; if (model.IsAddNew) { model.Result = WarrantyService.AddWarranty(dto); } else { model.Result = WarrantyService.UpdateWarranty(dto); } } else { model.FillTeamsSelectList(TeamService.GetTeams()); model.UserSelectList = new List <SelectListItem>(); } return(PartialView("_WarrantyEditPartial", model)); }
public void AddRemoveWarrantyTest() { var teamDto = SeedTeam(); var userDto = SeedUser(); WarrantyDto dto = new WarrantyDto() { WarrantyId = Guid.NewGuid(), TeamId = teamDto.TeamId, UserId = userDto.UserId, WarrantyName = TEST_WARRANTY_NAME, WarrentyDescription = TEST_WARRANT_DESC }; var addResult = Service.AddWarranty(dto); Assert.IsTrue(addResult.IsSuccess); var warranty = Service.GetWarranty(dto.WarrantyId); Assert.IsNotNull(warranty); Assert.AreEqual(dto.WarrantyId, warranty.WarrantyId); Assert.AreEqual(dto.WarrantyName, warranty.WarrantyName); Assert.AreEqual(dto.WarrentyDescription, warranty.WarrentyDescription); dto.WarrentyDescription = TEST_WARRANT_DESC_2; var updateResult = Service.UpdateWarranty(dto); Assert.IsTrue(updateResult.IsSuccess); warranty = Service.GetWarranty(dto.WarrantyId); Assert.IsNotNull(warranty); Assert.AreEqual(TEST_WARRANT_DESC_2, warranty.WarrentyDescription); var deleteResult = Service.DeleteWarranty(dto.WarrantyId); Assert.IsTrue(deleteResult.IsSuccess); DeleteSeededTeam(teamDto.TeamId); DeleteSeededUser(userDto.UserId); }