public int Update(Data.Models.Line line, int userId) { Data.Models.Line oldLine = _lineRepository.Table.Where(w => w.Id == line.Id).FirstOrDefault(); if (oldLine != null) { if (line.IsActive != oldLine.IsActive) { this._lineMachineActiveHistoryRepository.Insert(new LineMachineActiveHistory { LineId = line.Id, MachineId = null, IsActive = line.IsActive, UpdateBy = userId, UpdateDate = DateTime.UtcNow, }); } oldLine.Name = line.Name; oldLine.Location = line.Location; oldLine.InCharge = line.InCharge; oldLine.Description = line.Description; // oldLine.PlantId = line.PlantId; oldLine.IsActive = line.IsActive; _lineRepository.Update(oldLine); return(oldLine.Id); } else { return(0); } }
public void UpdateIsShutdown(int Id, bool IsShutdown) { Data.Models.Line oldLine = _lineRepository.Table.Where(w => w.Id == Id).FirstOrDefault(); if (oldLine != null) { oldLine.IsShutdown = IsShutdown; _lineRepository.Update(oldLine); } }
public int[] Delete(int[] ids) { List <int> lineIds = new List <int>(); foreach (int id in ids) { if (_lineRepository.Table.Any(a => a.Machines.Any(b => b.LineId == id))) { lineIds.Add(id); } else { Data.Models.Line Line = _lineRepository.Table.FirstOrDefault(w => w.Id == id); _lineRepository.Delete(Line); } } return(lineIds.ToArray()); }
public int Add(Data.Models.Line line) { _lineRepository.Insert(line); return(line.Id); }