public int Update(Data.Models.Plant plant) { Data.Models.Plant oldPlant = _plantRepository.Table.FirstOrDefault(w => w.Id == plant.Id); if (oldPlant != null) { oldPlant.Name = plant.Name; oldPlant.Location = plant.Location; oldPlant.PlantInCharge = plant.PlantInCharge; oldPlant.SiteId = plant.SiteId; _plantRepository.Update(oldPlant); return(plant.Id); } else { return(0); } }
public int[] Delete(int[] ids) { List <int> siteIds = new List <int>(); foreach (int id in ids) { if (_plantRepository.Table.Any(a => a.Machines.Any(b => b.PlantId == id))) { siteIds.Add(id); } else { Data.Models.Plant Plant = _plantRepository.Table.FirstOrDefault(w => w.Id == id); _plantRepository.Delete(Plant); } } return(siteIds.ToArray()); }
public int Add(Data.Models.Plant plant) { _plantRepository.Insert(plant); return(plant.Id); }