public bool AddTreatmentCategory(Model.TreatmentCategory entity) { var validation = new TreatmentCategoryValidation.TreatmentCategoryEntityValidate().Validate(entity); if (!validation.IsValid) { throw new ValidationException(validation.Errors); } using (var db = new Model.PhysicManagementEntities()) { entity.IsActive = true; db.TreatmentCategory.Add(entity); return(db.SaveChanges() == 1); } }
public bool UpdateTreatmentCategory(Model.TreatmentCategory entity) { var validation = new TreatmentCategoryValidation.TreatmentCategoryEntityValidate().Validate(entity); if (!validation.IsValid) { throw new ValidationException(validation.Errors); } using (var db = new Model.PhysicManagementEntities()) { var Entity = db.TreatmentCategory.Find(entity.Id); Entity.Title = entity.Title; Entity.Description = entity.Description; Entity.EnglishTitle = entity.EnglishTitle; return(db.SaveChanges() == 1); } }