public bool UpdatePhysicTreatmentPlan(Model.PhysicTreatmentPlan entity) { var validation = new PhysicTreatmentPlanValidate().Validate(entity); if (!validation.IsValid) { throw new ValidationException(validation.Errors.ToString()); } using (var db = new Model.PhysicManagementEntities()) { var Entity = db.PhysicTreatmentPlan.Find(entity.Id); if (Entity == null) { throw Common.MegaException.ThrowException("این رکورد در پایگاه داده پیدا نشد."); } Entity.PhysicId = entity.PhysicId; Entity.DoctorComment = entity.DoctorComment; Entity.DoctorFullName = entity.DoctorFullName; Entity.DoctorId = entity.DoctorId; Entity.Fields = entity.Fields; Entity.IsApprovedByDoctor = entity.IsApprovedByDoctor; Entity.MedicalRecordId = entity.MedicalRecordId; Entity.PhysicApplyDate = entity.PhysicApplyDate; Entity.PhysicComment = entity.PhysicComment; Entity.PhysicFullName = entity.PhysicFullName; Entity.PlanNo = entity.PlanNo; return(db.SaveChanges() == 1); } }
public PhysicTreatmentPlan AddPhysicTreatmentPlan(Model.PhysicTreatmentPlan entity) { var validation = new PhysicTreatmentPlanValidate().Validate(entity); if (!validation.IsValid) { throw new ValidationException(validation.Errors.ToString()); } using (var db = new Model.PhysicManagementEntities()) { var result = db.PhysicTreatmentPlan.Add(entity); if (result == null) { return(null); } db.SaveChanges(); return(result); } }