public bool UpdateDoctorAlarm(Model.DoctorAlarm entity) { var validation = new DoctorAlarmValidation.DoctorAlarmEntityValidate().Validate(entity); if (!validation.IsValid) { throw new ValidationException(validation.Errors); } using (var db = new Model.PhysicManagementEntities()) { var Entity = db.DoctorAlarm.Find(entity.Id); if (Entity == null) { throw Common.MegaException.ThrowException("این رکورد در پایگاه داده پیدا نشد."); } Entity.DoctorId = entity.DoctorId; Entity.IsSmsRecieveActive = entity.IsSmsRecieveActive; Entity.ReplacementResidentId = entity.ReplacementResidentId; Entity.ChangeDate = DateTime.Now; return(db.SaveChanges() == 1); } }
public bool AddDoctorAlarm(Model.DoctorAlarm entity) { var validation = new DoctorAlarmValidation.DoctorAlarmEntityValidate().Validate(entity); if (!validation.IsValid) { throw new ValidationException(validation.Errors); } using (var db = new Model.PhysicManagementEntities()) { entity.ChangeDate = DateTime.Now; db.DoctorAlarm.Add(entity); return(db.SaveChanges() == 1); } }