public Tuple <bool, string> AddOrUpdateMaster(MemberMaster member, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { _memberMasterRepository.Add(member); } else { // بررسی می کند که اگر برای این مستر قبلا کمیسیونی رای صادر شده است قابل حذف نباشد if (_requestRepository.Contains(x => x.MemberMasterId == member.Id && x.Vote != null)) { return(new Tuple <bool, string>(false, "عملیات حذف امکانپذیر نمی باشد.اعضای مورد نظر در لیست درخواست ها وجود دارد ")); } var memberMaster = _memberMasterRepository.Find(m => m.Id == member.Id); if (memberMaster == null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر یافت نشد")); } memberMaster.Date = member.Date; memberMaster.Name = member.Name; _memberMasterRepository.Update(memberMaster); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در ثبت")); } }
public Tuple <bool, string> AddOrUpdateDetail(MemberDetails details, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { _memberDetailsRepository.Add(details); } else { var master = _memberDetailsRepository.Where(x => x.Id == details.Id).Select(s => s.MemberMaster).FirstOrDefault(); if (master != null && _requestRepository.Contains(x => x.MemberMasterId == master.Id && x.Vote != null)) { return(new Tuple <bool, string>(false, "عملیات حذف امکانپذیر نمی باشد.اعضای مورد نظر در لیست درخواست ها وجود دارد ")); } var memberDetail = _memberDetailsRepository.Find(m => m.Id == details.Id); if (memberDetail == null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر یافت نشد")); } memberDetail.PersonName = details.PersonName; memberDetail.PostName = details.PostName; memberDetail.RowNumber = details.RowNumber; _memberDetailsRepository.Update(memberDetail); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در ثبت")); } }
public Tuple <bool, string> AddOrUpdate(Slider slider, StateOperation stateOperation, bool saveChange) { try { if (stateOperation == StateOperation.درج) { _sliderRepository.Add(slider); } else { _sliderRepository.Update(slider); } if (saveChange) { _unitOfWork.SaveChanges(); } return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public object Execute(dynamic op, ulong opid, StateOperation operationType) { CurrentOpid = opid; try { switch (operationType) { case StateOperation.ReadOrUpdate: return(op.Execute(this)); case StateOperation.Event: dynamic s = State; s.On(this, op); return(null); default: throw new Exception("internal error: unhandled case"); } } catch (Exception e) { // TODO for events and initialize, what with that? return(process.Serializer.SerializeException(e)); } finally { CurrentOpid = 0; } }
private bool DoStateOperation(StateOperation oper, int state) { var index = GetStateIndex(state); var offset = GetStateOffset(state); var binary = 1 << offset; if (index == 0) { switch (oper) { case StateOperation.HAS: return((simpleState & binary) == binary); case StateOperation.SET: simpleState |= binary; break; case StateOperation.RESET: simpleState ^= binary; break; } return(true); } if (states == null) { states = new Dictionary <int, int>(); } switch (oper) { case StateOperation.HAS: return(states.ContainsKey(index) && ((states[index] & binary) == binary)); case StateOperation.SET: if (!states.ContainsKey(index)) { states.Add(index, binary); } else { states[index] |= binary; } break; case StateOperation.RESET: if (states.ContainsKey(index)) { states[index] ^= binary; } break; } return(true); }
public Tuple <bool, string> AddOrUpdateRole(RoleModel roleModel, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { var exist = _roleRepository.Find(x => x.Name == roleModel.Name || x.NameFa == roleModel.NameFa); if (exist != null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام نقش وجود دارد")); } var role = new Role { Name = roleModel.Name, NameFa = roleModel.NameFa, CentralOrganizationId = roleModel.CentralOrganizationId, BranchProvinceId = roleModel.BranchProvinceId, UniversityId = roleModel.UniversityId, RoleType = roleModel.RoleType, XmlRoleAccess = roleModel.XmlRoleAccess }; _roleRepository.Add(role); } else { if (_roleRepository.Contains(x => x.Name == roleModel.Name && x.Id != roleModel.Id)) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام نقش(لاتین) وجود دارد")); } var role = _roleRepository.Find(x => x.Id == roleModel.Id); if (role == null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر یافت نشد")); } role.NameFa = roleModel.NameFa; role.Name = roleModel.Name; role.XmlRoleAccess = roleModel.XmlRoleAccess; _roleRepository.Update(role); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception exception) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddOrUpdateSigner(SignerModel signerModel, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { var signer = _signerRepository.Find(x => x.RequestType == signerModel.RequestType && x.RowNumber == signerModel.RowNumber); if (signer != null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر تکراری می باشد")); } Signer newSigner = new Signer { PostId = signerModel.PostId, RequestType = signerModel.RequestType, RowNumber = signerModel.RowNumber }; _signerRepository.Add(newSigner); } else { if (_signerRepository.Contains(x => x.Id != signerModel.Id && x.RequestType == signerModel.RequestType && x.RowNumber == signerModel.RowNumber)) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر تکراری می باشد")); } var signer = _signerRepository.Find(x => x.Id == signerModel.Id); if (signer == null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر یافت نشد")); } signer.PostId = signerModel.PostId; signer.RowNumber = signerModel.RowNumber; _signerRepository.Update(signer); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddOrUpdatePost(PostModel viewModelPost, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { var exist = _postRepository.Find(x => x.Name == viewModelPost.Name); if (exist != null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام سمت وجود دارد")); } Post post = new Post { Name = viewModelPost.Name, PostType = viewModelPost.PostType }; _postRepository.Add(post); } else { if (_postRepository.Contains(x => x.Name == viewModelPost.Name && x.Id != viewModelPost.Id)) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام سمت وجود دارد")); } var post = _postRepository.Find(x => x.Id == viewModelPost.Id); if (post == null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر یافت نشد")); } post.Name = viewModelPost.Name; post.PostType = viewModelPost.PostType; _postRepository.Update(post); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception) { return(new Tuple <bool, string>(false, "خطا در ثبت علیات ")); } }
public Tuple <bool, string> AddOrUpdateCollege(College college, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { _collegeRepository.Add(college); } else { _collegeRepository.Update(college); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddOrUpdate(TextDefault textDefault, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { _textVoteService.Add(textDefault); } else { _textVoteService.Update(textDefault); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddListAuthentication(List <AuthenticationModel> listAuthenticationModel, StateOperation stateOperation) { try { var listAuthen = listAuthenticationModel.Select(item => new Authentication { IdentityCode = item.IdentityCode, AuthenticationType = item.AuthenticationType, CentralOrganizationId = item.CentralOrganizationId, BranchProvinceId = item.BranchProvinceId, UniversityId = item.UniversityId }).ToList(); _authenticationRepository.Add(listAuthen); _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddOrUpdateAuthentication(AuthenticationModel authenticationModel, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { var authentication = _authenticationRepository.Find(x => x.IdentityCode == authenticationModel.IdentityCode); if (authentication != null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : کد شناسایی مورد نظر تکراری می باشد")); } Authentication newAuthentication = new Authentication { AuthenticationType = authenticationModel.AuthenticationType, IdentityCode = authenticationModel.IdentityCode, CentralOrganizationId = authenticationModel.CentralOrganizationId, BranchProvinceId = authenticationModel.BranchProvinceId, UniversityId = authenticationModel.UniversityId }; _authenticationRepository.Add(newAuthentication); } else { if (_authenticationRepository.Contains(x => x.Id != authenticationModel.Id && x.IdentityCode == authenticationModel.IdentityCode)) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : کد شناسایی مورد نظر تکراری می باشد")); } var authentication = _authenticationRepository.Find(x => x.Id == authenticationModel.Id); if (authentication == null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر یافت نشد")); } authentication.IdentityCode = authenticationModel.IdentityCode; authentication.AuthenticationType = authenticationModel.AuthenticationType; //authentication.CentralOrganizationId = authenticationModel.CentralOrganizationId; //authentication.BranchProvinceId = authenticationModel.BranchProvinceId; //authentication.UniversityId = authenticationModel.UniversityId; _authenticationRepository.Update(authentication); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddOrUpdatefieldofStudy(FieldofStudy fieldofStudy, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { _fieldofStudyRepository.Add(fieldofStudy); } else { _fieldofStudyRepository.Update(fieldofStudy); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
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> AddOrUpdateStructure(OrganizationStructureName structure, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { var authentication = _organizationStructureNameRepository.Find(x => x.Name == structure.Name); if (authentication != null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام مورد نظر تکراری می باشد")); } _organizationStructureNameRepository.Add(structure); } else { if (_organizationStructureNameRepository.Contains(x => x.Id != structure.Id && x.Name == structure.Name)) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام مورد نظر تکراری می باشد")); } _organizationStructureNameRepository.Update(structure); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> AddOrUpdateSpecialEducation(SpecialEducationModel specialEducationModel, StateOperation stateOperation) { try { if (stateOperation == StateOperation.درج) { var specialEducation = _specialEducationRepository.Find(x => x.Name == specialEducationModel.Name); if (specialEducation != null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام مورد نظر تکراری می باشد")); } SpecialEducation newAuthentication = new SpecialEducation { Name = specialEducationModel.Name }; _specialEducationRepository.Add(newAuthentication); } else { if (_specialEducationRepository.Contains(x => x.Id != specialEducationModel.Id && x.Name == specialEducationModel.Name)) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : نام مورد نظر تکراری می باشد")); } var authentication = _specialEducationRepository.Find(x => x.Id == specialEducationModel.Id); if (authentication == null) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات : رکورد مورد نظر یافت نشد")); } authentication.Name = specialEducationModel.Name; _specialEducationRepository.Update(authentication); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }