/// <summary> /// ذخیره درخواست کمیسیون یا شورا به همراه پروفایل و دانشجو و شخص /// </summary> /// <param name="commissionModel"></param> /// <returns></returns> public Tuple <bool, string, long> AddCommissionRequest(CommissionModel commissionModel, long universityId) { try { //واکشی درخواست اگر وجود دارد var request = _requestRepository.Where(i => i.Id == commissionModel.Id).Include(i => i.Commission) .Include(i => i.MemberMaster).FirstOrDefault() ?? new Request(); request.RequestType = commissionModel.RequestType; request.NumberofRemainingUnits = commissionModel.NumberofRemainingUnits; request.NumberofSpentUnits = commissionModel.NumberofSpentUnits; request.RequestStatus = commissionModel.RequestStatus; request.Description = commissionModel.Description; request.MemberMaster = _memberMasterRepository.Where(d => d.RequestType == RequestType.Comision) .OrderByDescending(p => p.Id).FirstOrDefault(); var x = new PersianCalendar(); commissionModel.Date = x.ToDateTime(commissionModel.Date.Year, commissionModel.Date.Month, commissionModel.Date.Day, 0, 0, 0, 0, 0); //درج درخواست به همراه کمیسیون if (request.Id > 0) { request.Commission.CommissionNumber = commissionModel.CommissionNumber; request.Commission.Date = commissionModel.Date; request.Commission.Description = commissionModel.Description; _requestRepository.Update(request); } else { request.PersonId = commissionModel.PersonId; request.Commission = new Commission { CommissionNumber = commissionModel.CommissionNumber, Date = commissionModel.Date, Description = commissionModel.Description }; _requestRepository.Add(request); } //آپدیت موارد خاص آموزشی مربوط به درخواست _commissionSpecialEducationRepository.Delete(c => c.CommissionId == commissionModel.Id); commissionModel.CommissionSpecialEducations.ForEach(c => c.CommissionId = commissionModel.Id); _commissionSpecialEducationRepository.Add(commissionModel.CommissionSpecialEducations); _unitOfWork.SaveChanges(); return(new Tuple <bool, string, long>(true, "عملیات ثبت به درستی انجام شد", request.Id)); } catch (Exception exception) { return(new Tuple <bool, string, long>(false, "خطا در ثبت درخواست", 0)); } }
/// <summary> /// ذخیره درخواست شورا به همراه پروفایل و دانشجو و شخص /// </summary> /// <param name="requestModel"></param> /// <returns></returns> public Tuple <bool, string, long> AddCouncilRequest(CouncilModel requestModel, long universityId) { try { //واکشی درخواست اگر وجود دارد var request = _requestRepository.Where(i => i.Id == requestModel.Id).Include(i => i.Council) .Include(i => i.MemberMaster).FirstOrDefault() ?? new Request(); request.RequestType = requestModel.RequestType; request.NumberofRemainingUnits = requestModel.NumberofRemainingUnits; request.NumberofSpentUnits = requestModel.NumberofSpentUnits; request.RequestStatus = requestModel.RequestStatus; request.Description = requestModel.Description; request.MemberMaster = _memberMasterRepository.Where(d => d.RequestType == RequestType.Council) .OrderByDescending(p => p.Id).FirstOrDefault(); var x = new PersianCalendar(); requestModel.Date = x.ToDateTime(requestModel.Date.Year, requestModel.Date.Month, requestModel.Date.Day, 0, 0, 0, 0, 0); //درج درخواست به همراه شورا if (request.Id > 0) { request.Council.CouncilNumber = requestModel.CouncilNumber; request.Council.Date = requestModel.Date; request.Council.Description = requestModel.Description; request.Council.ProblemText = requestModel.ProblemsCouncil; _requestRepository.Update(request); } else { request.PersonId = requestModel.PersonId; request.Council = new Council { CouncilNumber = requestModel.CouncilNumber, Date = requestModel.Date, ProblemText = requestModel.ProblemsCouncil, Description = requestModel.Description }; _requestRepository.Add(request); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string, long>(true, "عملیات ثبت به درستی انجام شد", request.Id)); } catch (Exception exception) { return(new Tuple <bool, string, long>(false, "خطا در ثبت درخواست", 0)); } }
/// <summary> /// ذخیره موقت درخواست به همراه پروفایل و دانشجو و شخص /// </summary> /// <param name="requestModel"></param> /// <returns></returns> public Tuple <bool, string> AddorUpdateRequest(RequestModel requestModel) { try { var student = _studentRepository.Where(s => s.StudentNumber == requestModel.StudentNumber).FirstOrDefault() ?? new Student(); student.StudentNumber = requestModel.StudentNumber; student.FieldofStudyId = requestModel.FieldofStudyId; //student.Grade = requestModel.Grade; //student.MilitaryServiceStatus = requestModel.MilitaryServiceStatus; var profile = _profileRepository.Where(p => p.NationalCode == requestModel.NationalCode).FirstOrDefault() ?? new Profile { Name = requestModel.Name, Family = requestModel.Family, NationalCode = requestModel.NationalCode, //Gender = requestModel.Gender }; var request = _requestRepository.Find(i => i.Id == requestModel.Id) ?? new Request(); request.RequestType = requestModel.RequestType; request.NumberofRemainingUnits = requestModel.NumberofRemainingUnits; request.NumberofSpentUnits = requestModel.NumberofSpentUnits; request.RequestStatus = requestModel.RequestStatus; request.Description = requestModel.Description; long personId = 0; if (profile.PersonId == 0) { Person person = new Person { Profile = profile, Student = student }; _personRepository.Add(person); personId = person.Id; } else { personId = profile.PersonId; student.PersonId = profile.PersonId; _studentRepository.AddOrUpdate(s => s.PersonId, student); } if (request.Id > 0) { _requestRepository.Update(request); } else { var member = _memberMasterRepository.Where(m => m.Active).FirstOrDefault(); request.PersonId = personId; if (member != null) { request.MemberMasterId = member.Id; } _requestRepository.Add(request); } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات ثبت به درستی انجام شد")); } catch (Exception exception) { return(new Tuple <bool, string>(false, "خطا در ثبت درخواست")); } }
public IQueryable <MemberMaster> GetMasters(long univercityId, RequestType requestType) { return(_memberMasterRepository.Where(x => x.UniversityId == univercityId && x.RequestType == requestType)); }