public void TestUpdateInterestPoint() { BoraNowSeeder.Seed(); var ipbo = new InterestPointBusinessObject(); var resList = ipbo.List(); var item = resList.Result.FirstOrDefault(); var cbo = new CompanyBusinessObject(); var pbo = new ProfileBusinessObject(); var profile = new Profile("II", "AA"); pbo.Create(profile); var company = new Company("kfc", "you", "9111222", "11111", profile.Id); cbo.Create(company); var interestPoint = new InterestPoint("a", "b", "c", "d", "e", "f", "g", true, true, company.Id); item.Name = interestPoint.Name; item.Address = interestPoint.Address; item.ClosingDays = interestPoint.ClosingDays; item.ClosingHours = interestPoint.ClosingHours; item.Description = interestPoint.Description; item.OpeningHours = interestPoint.OpeningHours; item.PhotoPath = interestPoint.PhotoPath; item.CovidSafe = interestPoint.CovidSafe; item.Status = interestPoint.Status; item.CompanyId = interestPoint.CompanyId; var resUpdate = ipbo.Update(item); resList = ipbo.List(); Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Name == interestPoint.Name && resList.Result.First().Address == interestPoint.Address && resList.Result.First().ClosingHours == interestPoint.ClosingHours && resList.Result.First().Description == interestPoint.Description && resList.Result.First().ClosingDays == interestPoint.ClosingDays && resList.Result.First().OpeningHours == interestPoint.OpeningHours && resList.Result.First().PhotoPath == interestPoint.PhotoPath && resList.Result.First().CovidSafe == interestPoint.CovidSafe && resList.Result.First().Status == interestPoint.Status && resList.Result.First().CompanyId == interestPoint.CompanyId); }
public ActionResult Update([FromBody] InterestPointViewModel c) { var currentResult = _bo.Read(c.Id); if (!currentResult.Success) { return(new ObjectResult(HttpStatusCode.InternalServerError)); } var current = currentResult.Result; if (current == null) { return(NotFound()); } if (current.Name == c.Name && current.Description == c.Description && current.Address == c.Address && current.PhotoPath == c.PhotoPath && current.OpeningHours == c.OpeningHours && current.ClosingHours == c.ClosingHours && current.ClosingDays == c.ClosingDays && current.CovidSafe == c.CovidSafe && current.Status == c.Status && current.CompanyId == c.CompanyId) { return(new ObjectResult(HttpStatusCode.NotModified)); } if (current.Address != c.Address) { current.Address = c.Address; } if (current.Name != c.Name) { current.Name = c.Name; } if (current.Description != c.Description) { current.Description = c.Description; } if (current.PhotoPath != c.PhotoPath) { current.PhotoPath = c.PhotoPath; } if (current.OpeningHours != c.OpeningHours) { current.OpeningHours = c.OpeningHours; } if (current.ClosingHours != c.ClosingHours) { current.ClosingHours = c.ClosingHours; } if (current.ClosingDays != c.ClosingDays) { current.ClosingDays = c.ClosingDays; } if (current.CovidSafe != c.CovidSafe) { current.CovidSafe = c.CovidSafe; } if (current.Status != c.Status) { current.Status = c.Status; } if (current.CompanyId != c.CompanyId) { current.CompanyId = c.CompanyId; } var updateResult = _bo.Update(current); if (!updateResult.Success) { return(new ObjectResult(HttpStatusCode.InternalServerError)); } return(Ok()); }