/// <summary> /// Получить список заявок на доверенность /// </summary> /// <param name="request"></param> /// <param name="type"> /// Тип запроса /// 0 - запрос заявок на доверенность /// 1 - /// 2 - /// </param> /// <returns></returns> public ActionResult ReadApplicationList([DataSourceRequest] DataSourceRequest request, int type) { ApplicationPoaRepository poaRepository = new ApplicationPoaRepository(false); Expression <Func <LimsTmcInView, bool> > exp = m => m.StateType != TmcIn.TmcInStatuses.Closed && m.StateType != TmcIn.TmcInStatuses.Received1C && m.StateType != TmcIn.TmcInStatuses.SendedAdmission1C; if (type == 1) { exp = m => m.StateType == TmcIn.TmcInStatuses.Received1C || m.StateType == TmcIn.TmcInStatuses.SendedAdmission1C; } else if (type == 2) { var currentUser = UserHelper.GetCurrentEmployee(); var id = currentUser.Id; exp = m => (m.StateType == TmcIn.TmcInStatuses.AgreedResearchCenter && m.AgreementEmployeeId == id) || (m.StateType == TmcIn.TmcInStatuses.AgreedAccount && m.AccountantEmployeeId == id) || (m.StateType == TmcIn.TmcInStatuses.AgreedHead && m.ExecutorEmployeeId == id); } var qr = poaRepository.GetLimsTmcInViews(exp); if (type != 2) { qr = base.FilterByCurrentUser(qr, poaRepository.GetContext()); } qr = qr.OrderBy(m => m.CreatedDate); var data = qr; return(Json(data.ToDataSourceResult(request, o => new TmcInViewModel() { Id = o.Id, TmcInId = o.Id, ContractDate = o.ContractDate, ContractNumber = o.ContractNumber, IsFullDelivery = o.IsFullDelivery, LastDeliveryDate = o.LastDeliveryDate, OwnerEmployeeId = o.OwnerEmployeeId, Provider = o.Provider, ProviderBin = o.ProviderBin, StateType = o.StateType, CreatedEmployeeId = o.CreatedEmployeeId, StateTypeValue = o.StateTypeValue, //IsFullDeliveryValue = o.IsFullDeliveryValue, OwnerEmployeeValue = o.OwnerEmployeeValue, ExecutorEmployeeValue = o.ExecutorEmployeeValue, AgreementEmployeeValue = o.AgreementEmployeeValue, ExecutorEmployeeId = o.ExecutorEmployeeId, AgreementEmployeeId = o.AgreementEmployeeId, AccountantEmployeeId = o.AccountantEmployeeId, AccountantEmployeeValue = o.AccountantEmployeeValue, PowerOfAttorney = o.PowerOfAttorney, DayCount = o.DayCount, Comment = o.Comment }), JsonRequestBehavior.AllowGet)); }