public Tuple <bool, string, VoteModel> GetVote(long universityId, long voteId, RequestType requestType, AddressUrlFile addressUrlFile) { try { //var request = _requestRepository.Where(r => r.Id == voteId).Select(s => new { s.RequestType, s.Commission, s.Council,s.Vote }).FirstOrDefault(); var detailRequestModel = _requestService.DetailRequest(voteId, addressUrlFile); if (!detailRequestModel.Item1) { return(new Tuple <bool, string, VoteModel>(false, "عملیات با مشکل مواجه شده است", null)); } DateTime?dateVote; if (requestType == RequestType.Comision) { detailRequestModel.Item3.CommissionNumber = _commissionService.GetCommissionNumber(universityId).Item1; dateVote = _voteRepository.Where(w => w.Request.Commission.CommissionNumber == detailRequestModel.Item3.CommissionNumber). Select(s => s.DateVote).FirstOrDefault(); } else { detailRequestModel.Item3.CommissionNumber = _councilService.GetCouncilNumber(universityId).Item1; dateVote = _voteRepository.Where(w => w.Request.Council.CouncilNumber == detailRequestModel.Item3.CommissionNumber). Select(s => s.DateVote).FirstOrDefault(); } var vote = _requestRepository.Where(x => x.Id == voteId) .Select(v => new VoteModel { PersonId = v.Vote != null ? v.Vote.PersonId : 0, PersonIdOnBehalfof = v.Vote != null ? v.Vote.PersonId : 0, PostId = v.Vote != null ? v.Vote.PostId : 0, RequestId = voteId, DateVote = v.Vote != null ? v.Vote.DateVote : dateVote ?? DateTime.Now, VoteText = v.Vote != null ? v.Vote.VoteText : "", VoteDescription = v.Vote != null ? v.Vote.ReferText : "", VoteType = v.Vote != null ? v.Vote.VoteType : 0, VoteStatus = v.Vote != null ? v.Vote.VoteStatus : 0, RequestType = v.RequestType, Included = (v.RequestType == RequestType.Comision && v.Person.Profile.Gender == Gender.Male && v.Person.Student.MilitaryServiceStatus == MilitaryServiceStatus.Included), Name = v.Person.Profile.Name, Family = v.Person.Profile.Family, StudentNumber = v.Person.Student.StudentNumber, FieldofStudy = v.Person.Student.FieldofStudy.OrganizationStructureName.Name, FieldofStudyId = v.Person.Student.FieldofStudyId, Grade = v.Person.Student.Grade.ToString(), NationalCode = v.Person.Profile.NationalCode //Description = v.Request.Cartables.FirstOrDefault(c => // c.CartableStatus == CartableStatus.Verdict && // c.CartableValidation == CartableValidation.Valid).Description }).FirstOrDefault(); if (vote == null) { return(new Tuple <bool, string, VoteModel>(false, "عملیات با مشکل مواجه شده است", null)); } vote.DetailRequestModel = detailRequestModel.Item3; return(new Tuple <bool, string, VoteModel>(true, "", vote)); } catch (Exception exception) { return(new Tuple <bool, string, VoteModel>(false, "عملیات با مشکل مواجه شده است", null)); } }