public void TestAddCarpentryService() { var service = new CarpentryServiceService(carpentryWebsiteContext); CarpentryService itemToAdd = new CarpentryService { CarpentryServiceId = 105, Name = "Name", Price = 5000, Description = "Different desc", CarpentryServiceTypeId = 500 }; service.AddCarpentryService(itemToAdd); CarpentryService result = service.GetCarpentryServiceDetails(105); Assert.Equal(itemToAdd, result); }
public void TestEditCarpentryServices() { string expectedDescription = "Different desc"; var service = new CarpentryServiceService(carpentryWebsiteContext); CarpentryService itemToAdd = new CarpentryService { CarpentryServiceId = 14, Name = "Name", Price = 5000, Description = "Different desc", CarpentryServiceTypeId = 500 }; service.AddCarpentryService(itemToAdd); carpentryWebsiteContext.Entry(service.GetCarpentryServiceDetails(14)).State = EntityState.Detached; service.UpdateCarpentryService(new CarpentryService { CarpentryServiceId = 14, Name = "Name", Price = 5000, Description = "Different desc", CarpentryServiceTypeId = 501 }); CarpentryService result = service.GetCarpentryServiceDetails(14); Assert.Equal(expectedDescription, result.Description); }
public int Create([FromBody] CarpentryService carpentryService) { return(carpentryServiceService.AddCarpentryService(carpentryService)); }