public ActionResult Update([FromBody] InterestPointCategoryInterestPointViewModel 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.CategoryId == c.CategoryId && current.InterestPointId == c.InterestPointId) { return(new ObjectResult(HttpStatusCode.NotModified)); } if (current.CategoryId != c.CategoryId) { current.CategoryId = c.CategoryId; } if (current.InterestPointId != c.InterestPointId) { current.InterestPointId = c.InterestPointId; } var updateResult = _bo.Update(current); if (!updateResult.Success) { return(new ObjectResult(HttpStatusCode.InternalServerError)); } return(Ok()); }
public void TestUpdateInterestpointCategory() { BoraNowSeeder.Seed(); var ipcipbo = new InterestPointCategoryInterestPointBusinessObject(); var resList = ipcipbo.List(); var item = resList.Result.FirstOrDefault(); var ipbo = new InterestPointBusinessObject(); var cipbo = new CategoryInterestPointBusinessObject(); var pbo = new ProfileBusinessObject(); var profile = new Profile("II", "AA"); pbo.Create(profile); var c = new CompanyBusinessObject(); var company = new Company("A", "B", "12345678", "1234567", profile.Id); c.Create(company); var interestPoint = new InterestPoint("a", "b", "c", "d", "e", "f", "g", true, true, company.Id); var category = new CategoryInterestPoint("vegan"); ipbo.Create(interestPoint); cipbo.Create(category); var interestPointCategoryInterestPoint = new InterestPointCategoryInterestPoint(interestPoint.Id, category.Id); item.InterestPointId = interestPointCategoryInterestPoint.InterestPointId; item.CategoryId = interestPointCategoryInterestPoint.CategoryId; var resUpdate = ipcipbo.Update(item); resList = ipcipbo.List(); Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().InterestPointId == interestPoint.Id && resList.Result.First().CategoryId == category.Id); }