Exemple #1
0
        //public dynamic GetList(string _search, long nd, int rows, int? page, string sidx, string sord, string filters = "")
        //{
        //    // Construct where statement
        //    string strWhere = GeneralFunction.ConstructWhere(filters);
        //    string filter = null;
        //    GeneralFunction.ConstructWhereInLinq(strWhere, out filter);
        //    if (filter == "") filter = "true";

        //    // Get Data
        //    var q = _companyInfoService.GetQueryable();

        //    var query = (from model in q
        //                 select new
        //                 {
        //                     model.Id,
        //                     model.Name,
        //                     model.Address,
        //                     model.City,
        //                     model.PostalCode,
        //                     model.PhoneNumber,
        //                     model.FaxNumber,
        //                     model.Email,
        //                     model.Website,
        //                     model.NPWP,
        //                     model.NPWPDate,
        //                     model.CreatedAt,
        //                     model.UpdatedAt,
        //                 }).Where(filter).OrderBy(sidx + " " + sord); //.ToList();

        //    var list = query.AsEnumerable();

        //    var pageIndex = Convert.ToInt32(page) - 1;
        //    var pageSize = rows;
        //    var totalRecords = query.Count();
        //    var totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
        //    // default last page
        //    if (totalPages > 0)
        //    {
        //        if (!page.HasValue)
        //        {
        //            pageIndex = totalPages - 1;
        //            page = totalPages;
        //        }
        //    }

        //    list = list.Skip(pageIndex * pageSize).Take(pageSize);

        //    return Json(new
        //    {
        //        total = totalPages,
        //        page = page,
        //        records = totalRecords,
        //        rows = (
        //            from model in list
        //            select new
        //            {
        //                id = model.Id,
        //                cell = new object[] {
        //                    model.Id,
        //                    model.Name,
        //                    model.Address,
        //                    model.City,
        //                    model.PostalCode,
        //                    model.PhoneNumber,
        //                    model.FaxNumber,
        //                    model.Email,
        //                    model.Website,
        //                    model.NPWP,
        //                    model.NPWPDate,
        //                    model.CreatedAt,
        //                    model.UpdatedAt,
        //              }
        //            }).ToArray()
        //    }, JsonRequestBehavior.AllowGet);
        //}


        public dynamic GetInfo(int Id)
        {
            CompanyInfo model = new CompanyInfo();

            try
            {
                model = _companyInfoService.GetObjectById(Id);
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Id,
                model.Name,
                model.Address,
                model.City,
                model.PostalCode,
                model.PhoneNumber,
                model.FaxNumber,
                model.Email,
                model.Website,
                model.NPWP,
                model.NPWPDate
            }, JsonRequestBehavior.AllowGet));
        }
        public FPMachine VHasCompany(FPMachine fpMachine, ICompanyInfoService _companyInfoService)
        {
            CompanyInfo companyInfo = _companyInfoService.GetObjectById(fpMachine.CompanyInfoId);

            if (companyInfo == null)
            {
                fpMachine.Errors.Add("Generic", "Company Tidak valid");
            }
            return(fpMachine);
        }
Exemple #3
0
        public BranchOffice VHasCompany(BranchOffice branchOffice, ICompanyInfoService _companyInfoService)
        {
            CompanyInfo companyInfo = _companyInfoService.GetObjectById(branchOffice.CompanyInfoId.GetValueOrDefault());

            if (companyInfo == null)
            {
                //  branchOffice.Errors.Add("Generic", "Company Tidak valid");
            }
            return(branchOffice);
        }