public bool CreateCompanyLocation(CompanyLocationCreate model) { var entity = new CompanyLocation() { CompanyID = model.CompanyID, Street = model.Street, City = model.City, State = model.State, Zip = model.Zip, }; var profile = (new CompanyProfileServices(_userId).GetCompanyByCompanyId(model.CompanyID)); //profile. using (var ctx = new ApplicationDbContext()) { ctx.CompanyLocations.Add(entity); ctx.SaveChanges(); DataTable table = new DataTable("Companies"); foreach (DataRow dr in table.Rows) { if ((int)dr["CompanyID"] == model.CompanyID) { dr["CompanyLocation_ComapnyID"] = model.CompanyID; } } ctx.SaveChanges(); return(true); } }
public IHttpActionResult Post(CompanyLocationCreate companyLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCompanyLocationService(); if (!service.CreateCompanyLocation(companyLocation)) { return(InternalServerError()); } return(Ok()); }