private HierSalesViewModel GetHierSalesViewModel(RHHeader item) { HierSalesViewModel model = new HierSalesViewModel() { Id = item.ID, RayonCode = item.RayonCode, RayonType = item.RayonType, PlantCode = item.Plant, BUMNik = item.BUM, NSMNik = item.NSM, ASMNik = item.ASM, FSSNik = item.FSS, SLMNik = item.SLM, ValidFromDate = item.ValidFrom, ValidToDate = item.ValidTo }; model.FormattedValidFrom = item.ValidFrom.ToString(_formattedDate); model.FormattedValidTo = item.ValidTo.ToString(_formattedDate); model.BUMFullname = item.BUMObj1 == null ? null : item.BUMObj1.FullName; model.NSMFullname = item.NSMObj1 == null ? null : item.NSMObj1.FullName; model.ASMFullname = item.ASMObj1 == null ? null : item.ASMObj1.FullName; model.FSSFullname = item.FSSObj1 == null ? null : item.FSSObj1.FullName; model.SLMFullname = item.SLMObj1 == null ? null : item.SLMObj1.FullName; return(model); }
private RayonViewModel GetRayonViewModelBySales(RHHeader item) { RayonViewModel model = new RayonViewModel() { RayonCode = item.RayonCode, SalesmanNIK = item.SLM }; if (item.SLMObj1 != null) { model.SalesmanFullname = item.SLMObj1.FullName; } return(model); }
private SalesmanViewModel GetSalesmanViewModel(RHHeader item) { SalesmanViewModel model = new SalesmanViewModel() { NIK = item.SLMObj1.NIK, Fullname = item.SLMObj1.FullName, IsRole = item.SLMObj1.Role, ValidFromDate = item.ValidFrom, ValidToDate = item.ValidTo }; model.FormattedValidFrom = item.ValidFrom.ToString(AppConstant.DefaultFormatDate); model.FormattedValidTo = item.ValidTo.ToString(AppConstant.DefaultFormatDate); return(model); }
private SupervisorViewModel GetSupervisorViewModel(RHHeader item) { SupervisorViewModel model = new SupervisorViewModel() { NIK = item.FSSObj1.NIK, Fullname = item.FSSObj1.FullName, IsRole = item.FSSObj1.Role, DefaultRayonType = item.FSSObj1.DefaultRayonType, ValidFromDate = item.ValidFrom, ValidToDate = item.ValidTo }; model.FormattedValidFrom = item.ValidFrom.ToString(AppConstant.DefaultFormatDate); model.FormattedValidTo = item.ValidTo.ToString(AppConstant.DefaultFormatDate); return(model); }
private SalesCustomerViewModel GetSalesRayonViewModel(RHDetail item, RHHeader rhh) { SalesCustomerViewModel model = new SalesCustomerViewModel() { RayonCode = item.RayonCode, CustomerCode = item.Customer, ValidFromDate = item.ValidFrom, ValidToDate = item.ValidTo }; model.FormattedValidFrom = item.ValidFrom.ToString(_formattedDate); model.FormattedValidTo = item.ValidTo.ToString(_formattedDate); model.CustomerName = item.CustomerObj == null ? null : item.CustomerObj.CustomerName; if (rhh != null && rhh.SLMObj1 != null) { model.SLMNik = rhh.SLMObj1.NIK; model.SLMFullname = rhh.SLMObj1.FullName; } return(model); }
public JDatatableResponse GetDatatableCustomer(RayonDatatableViewModel model) { JDatatableResponse result = new JDatatableResponse(); string[] arrOrderColumn = new string[] { "CreatedOn" , "RayonCode" , "CreatedOn" , "CreatedOn" , "Customer" , "CustomerObj.CustomerName" , "ValidFrom" , "ValidTo" }; if (_userAuth == null) { return(result); } DateTime today = DateTime.UtcNow.ToUtcID().Date; IRepository <RHDetail> repo = _unitOfWork.GetRepository <RHDetail>(); repo.Includes = new string[] { "CustomerObj" }; repo.Condition = PredicateBuilder.True <RHDetail>().And(x => x.RayonCode.Equals(model.RayonCode)); repo.Condition = repo.Condition.And(x => x.ValidTo >= today); if (!string.IsNullOrEmpty(model.Keyword)) { repo.Condition = repo.Condition.And(x => x.RayonCode.Contains(model.Keyword) || x.Customer.Contains(model.Keyword) || x.CustomerObj.CustomerName.Contains(model.Keyword)); } SetDatatableRepository(model, arrOrderColumn, ref repo, ref result); if (model.Length > -1 && result.TotalRecords == 0) { return(result); } List <RHDetail> listItem = repo.Find(); if (listItem == null) { return(result); } #region get salesman on a rayon IRepository <RHHeader> repoRHH = _unitOfWork.GetRepository <RHHeader>(); repoRHH.Includes = new string[] { "SLMObj1" }; repoRHH.Condition = PredicateBuilder.True <RHHeader>().And(x => x.RayonCode.Equals(model.RayonCode) && x.ValidTo >= today); repoRHH.OrderBy = new SqlOrderBy("CreatedOn", SqlOrderType.Descending); RHHeader rhh = repoRHH.Find().FirstOrDefault(); #endregion List <SalesCustomerViewModel> listData = new List <SalesCustomerViewModel>(); foreach (var item in listItem) { listData.Add(GetSalesRayonViewModel(item, rhh)); } result.Data = listData; return(result); }