public Tuple <bool, string> AddOrUpdateEducationGroup(EducationalGroup educationalGroup, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { _educationalGroupRepository.Add(educationalGroup); } else { _educationalGroupRepository.Update(educationalGroup); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddorUpdateStructureComplete(StructureTreeModel model) { var exist = _organizationStructureNameRepository.Find(x => x.Name == model.Text); if (exist != null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : عنوان وارد شده تکراریست")); } if (model.StructureType == StructureType.FieldofStudy) { return(new Tuple <bool, string>(false, "امکان ثبت اطلاعات برای سطح رشته آموزشی وجود ندارد")); } try { _unitOfWork.BeginTransaction(); // ذخیره در جدول ساختار var org = new OrganizationStructureName { Name = model.Text }; switch (model.StructureType) { case StructureType.University: org.StructureType = StructureType.College; break; case StructureType.College: org.StructureType = StructureType.EducationalGroup; break; case StructureType.EducationalGroup: org.StructureType = StructureType.FieldofStudy; break; } var result = AddOrUpdateStructure(org, StateOperation.درج); // پایان ذخیره در جدول ساختار switch (model.StructureType) { case StructureType.University: var college = new College { UniversityId = model.ParentId, OrganizationStructureNameId = org.Id, OrganizationStructureName = org }; result = AddOrUpdateCollege(college, StateOperation.درج); break; case StructureType.College: var edu = new EducationalGroup { CollegeId = model.ParentId, OrganizationStructureNameId = org.Id, OrganizationStructureName = org }; result = AddOrUpdateEducationGroup(edu, StateOperation.درج); break; case StructureType.EducationalGroup: var fs = new FieldofStudy { EducationalGroupId = model.ParentId, OrganizationStructureNameId = org.Id, OrganizationStructureName = org }; result = AddOrUpdatefieldofStudy(fs, StateOperation.درج); break; } _unitOfWork.CommitTransaction(); return(new Tuple <bool, string>(result.Item1, result.Item2)); } catch (Exception) { _unitOfWork.Rollback(); return(new Tuple <bool, string>(true, "خطای سیستمی، لطفا با پشتیبانی شرکت تماس حاصب فرمائید")); } }