public JsonResult DeleteConstruction(ParemetersConstruction paremetersConstruction, ParemetersRange paremetersRange) { Construction construction = ApplicationContext.Constructions.FirstOrDefault(x => x.Id == paremetersConstruction.ConstructionId); if (construction != null && construction.Id == paremetersConstruction.ConstructionId) { ApplicationContext.Constructions.Remove(construction); ApplicationContext.SaveChanges(); } return(GetConstructions(paremetersRange)); }
public JsonResult AddConstruction(ParemetersConstruction paremetersConstruction, ParemetersRange paremetersRange) { Construction construction = new Construction { Name = paremetersConstruction.Name, Address = paremetersConstruction.Address }; ApplicationContext.Constructions.Add(construction); ApplicationContext.SaveChanges(); return(GetConstructions(paremetersRange)); }
public JsonResult EditConstruction(ParemetersConstruction paremetersConstruction, ParemetersRange paremetersRange) { Construction construction = ApplicationContext.Constructions.FirstOrDefault(x => x.Id == paremetersConstruction.ConstructionId); if (construction != null && construction.Id == paremetersConstruction.ConstructionId) { construction.Name = paremetersConstruction.Name; construction.Address = paremetersConstruction.Address; ApplicationContext.Constructions.Update(construction); ApplicationContext.SaveChanges(); } return(GetConstructions(paremetersRange)); }