Ejemplo n.º 1
0
 public ActionResult GetRecruitmentCampaignList([DataSourceRequest] DataSourceRequest request, Rec_RecruitmentCampaignSearchModel model)
 {
     //return GetListDataAndReturn<Rec_RecruitmentCampaignModel, Rec_RecruitmentCampaignEntity, Rec_RecruitmentCampaignSearchModel>(request, model, ConstantSql.hrm_rec_sp_get_RecruitmentCampaign);
     string status = string.Empty;
     var service = new BaseService();
     ListQueryModel lstModel = new ListQueryModel
     {
         PageIndex = request.Page,
         PageSize = request.PageSize,
         Filters = ExtractFilterAttributes(request),
         Sorts = ExtractSortAttributes(request),
         AdvanceFilters = ExtractAdvanceFilterAttributes(model)
     };
     var listEntity = service.GetData<Rec_RecruitmentCampaignEntity>(lstModel, ConstantSql.hrm_rec_sp_get_RecruitmentCampaign, UserLogin, ref status);
     List<object> lstObjCosDetail = new List<object>();
     lstObjCosDetail.Add(1);
     lstObjCosDetail.Add(int.MaxValue - 1);
     var listRecCosDetail = service.GetData<Rec_RecCostDetailEntity>(lstObjCosDetail, ConstantSql.hrm_rec_sp_get_RecCosDetail, UserLogin,ref status);
     var listModel = new List<Rec_RecruitmentCampaignModel>();
     if (listEntity != null)
     {
         request.Page = 1;
         foreach (var item in listEntity)
         {
             var lstCosdetailByRecruimentcampain = listRecCosDetail.Where(s => s.RecCampaignID == item.ID).Sum(s => s.Amount);
             if (lstCosdetailByRecruimentcampain != null && lstCosdetailByRecruimentcampain != 0)
             {
                 item.Budget = lstCosdetailByRecruimentcampain;
             }
             var newModle = (Rec_RecruitmentCampaignModel)typeof(Rec_RecruitmentCampaignModel).CreateInstance();
             foreach (var property in item.GetType().GetProperties())
             {
                 newModle.SetPropertyValue(property.Name, item.GetPropertyValue(property.Name));
             }
             listModel.Add(newModle);
         }
         var dataSourceResult = listModel.ToDataSourceResult(request);
         if (listModel.FirstOrDefault().GetPropertyValue("TotalRow") != null)
         {
             dataSourceResult.Total = listModel.Count() <= 0 ? 0 : (int)listModel.FirstOrDefault().GetPropertyValue("TotalRow");
         }
         return Json(dataSourceResult, JsonRequestBehavior.AllowGet);
     }
     var listModelNull = new List<Rec_RecruitmentCampaignModel>();
     ModelState.AddModelError("Id", status);
     return Json(listModelNull.ToDataSourceResult(request, ModelState));
 }
Ejemplo n.º 2
0
 public ActionResult ExportRecruitmentCampaignList([DataSourceRequest] DataSourceRequest request, Rec_RecruitmentCampaignSearchModel model)
 {
     return ExportAllAndReturn<Rec_RecruitmentCampaignEntity, Rec_RecruitmentCampaignModel, Rec_RecruitmentCampaignSearchModel>(request, model, ConstantSql.hrm_rec_sp_get_RecruitmentCampaign);
 }
Ejemplo n.º 3
0
        public ActionResult ExportRecruitmentCampaignListByTemplate([DataSourceRequest] DataSourceRequest request, Rec_RecruitmentCampaignSearchModel model)
        {
            string status = string.Empty;
            var isDataTable = false;
            object obj = new Rec_RecruitmentCampaignModel();
            var services = new BaseService();
            var result = GetListData<Rec_RecruitmentCampaignModel, Rec_RecruitmentCampaignEntity, Rec_RecruitmentCampaignSearchModel>(request, model, ConstantSql.hrm_rec_sp_get_RecruitmentCampaign, ref status);
            if (model.IsCreateTemplateForDynamicGrid)
            {
                obj = result;
                isDataTable = false;
            }
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Rec_RecruitmentCampaignModel",
                    OutPutPath = path,
                    // HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = false
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            if (model.ExportId != Guid.Empty)
            {

                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                return Json(fullPath);
            }

            return Json(result.ToDataSourceResult(request));

        }