/// <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)); } }
public Tuple <bool, string> Delete(long requestId) { try { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { _cartableRepository.Delete(c => c.RequestId == requestId); _commissionRepository.Delete(c => c.RequestId == requestId); _councilRepository.Delete(c => c.RequestId == requestId); _attachmentRepository.Delete(a => a.RequestId == requestId); _voteRepository.Delete(v => v.RequestId == requestId); _archiveRepository.Delete(a => a.RequestId == requestId); _commissionSpecialEducationRepository.Delete(c => c.CommissionId == requestId); _requestRepository.Delete(r => r.Id == requestId); _unitOfWork.SaveChanges(); scope.Complete(); return(new Tuple <bool, string>(true, "عملیات حذف با موفقیت انجام شده است")); } } catch (Exception ex) { return(new Tuple <bool, string>(false, "عملیات حذف با مشکل مواجه شده است")); } }