public Resp_Binary Add(AlarmDTO model) { var alarm = model.GetPrototype <AlarmDTO, Alarm>(); if (alarm.CaptureId > 0) { var capture = _capture_repository.GetById(alarm.CaptureId); if (capture == null) { alarm.CaptureId = null; } } if (string.IsNullOrEmpty(model.HandlerTime)) { alarm.HandlerTime = null; } if (string.IsNullOrEmpty(model.GUID)) { model.GUID = Guid.NewGuid().ToString(); } _repository.Insert(alarm); if (_repository.UnitOfWork.Commite() > 0) { return(Resp_Binary.Add_Sucess); } return(Resp_Binary.Add_Failed); }
public Resp_Binary CreateOrUpdate(AlarmDTO model) { var exsits = _repository.GetByWhere(t => t.GUID == model.GUID).FirstOrDefault(); if (exsits.IsNull() || string.IsNullOrEmpty(model.GUID)) { var alarm = model.GetPrototype <AlarmDTO, Alarm>(); if (alarm.CaptureId > 0) { var capture = _capture_repository.GetById(alarm.CaptureId); if (capture == null) { alarm.CaptureId = null; } } if (string.IsNullOrEmpty(model.HandlerTime)) { alarm.HandlerTime = null; } if (string.IsNullOrEmpty(model.GUID)) { model.GUID = Guid.NewGuid().ToString(); } _repository.Insert(alarm); } else { exsits.IsDeal = model.IsDeal; exsits.Operator = model.Operator; exsits.Message = model.Message; if (!string.IsNullOrEmpty(model.HandlerTime)) { exsits.HandlerTime = model.HandlerTime.ToDateTime(); } else { exsits.HandlerTime = null; } _repository.Update(exsits); } if (_repository.UnitOfWork.Commite() > 0) { return(Resp_Binary.Add_Sucess); } return(Resp_Binary.Add_Failed); }