Beispiel #1
0
        public JsonResult Get(DatatableModel dt, NotificationModel filters)
        {
            try
            {
                NotificationServices service = new NotificationServices();
                PagerModel           pager   = dt.ToPager();
                var collection = service.Get(pager, filters);

                return(Json(new
                {
                    status = UI.Status.Success,
                    sEcho = dt.sEcho,
                    iTotalRecords = pager.TotalRecords,
                    iTotalDisplayRecords = pager.TotalRecords,
                    aaData = collection
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(new JsonResult
                {
                    Data = new { status = UI.Status.Error, data = ex.Message },
                });
            }
        }
Beispiel #2
0
        //datatableRequest Property Value
        //-----------------------------------
        //Data=null
        //Index=1
        //Page=0
        //Size=9
        //StartIndex=0
        //Total=0
        public ActionResult GetItems(DatatableData <ProductViewModel> datatableRequest, int?categoryId)
        {
            var imgPath = Constants.ImagePath + "/";
            //entities is of type IQueryable<Product>
            var entities = _productService.GetAll().Where(a => a.Status == (int)Constants.EnumProductStatus.Stocking);

            if (categoryId.HasValue && categoryId > 0)
            {
                entities = entities.Where(a => a.CategoryId == categoryId.Value || a.Category.ParentId == categoryId);
            }
            //models is of type IQueryable<ProductViewModel>
            //Map Product.Id to ProductViewModel.Id, begitu juga pada Price, ProductName, Image
            //Image -> get product images if any -> get main image -> then append it to image path , otherwise it's null
            //Order by price ascending
            //Convert Product which is mapped above to ProductViewModel
            var models = entities.Select(a => new ProductViewModel()
            {
                Id          = a.Id,
                Price       = a.Price,
                ProductName = a.Name,
                Image       = a.Images.Any() ?
                              a.Images.Any(x => x.Main == true) ?
                              imgPath + a.Images.FirstOrDefault(x => x.Main == true).Name : imgPath + a.Images.FirstOrDefault().Name :
                              null
            }).OrderBy(a => a.Price);

            return(Json(DatatableModel.Refresh(models, datatableRequest.Size, datatableRequest.Index)));
        }
Beispiel #3
0
        public JsonResult Get(DatatableModel dt, ProjectModel parameters)
        {
            try
            {
                SystemVariableServices SystemVariableServ = new SystemVariableServices();
                var ActiveProject = Convert.ToInt32(SystemVariableServ.GetSystemVariableValue("EstatusActiveProject"));

                ProjectServices ProjectServ = new ProjectServices();
                PagerModel      pager       = dt.ToPager();

                parameters.CompanyId = SessionWeb.User.CompanyId ?? -1;
                var collection = ProjectServ.GetProjectCollection(parameters, pager);

                return(Json(new
                {
                    status = UI.Status.Success,
                    sEcho = dt.sEcho,
                    iTotalRecords = pager.TotalRecords,
                    iTotalDisplayRecords = pager.TotalRecords,
                    aaData = collection.Data
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(new JsonResult
                {
                    Data = new { status = UI.Status.Error,
                                 data = ex.Message },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
        /// <summary>
        /// 获取登陆的JwtToken
        /// </summary>
        /// <param name="id"></param>
        public IActionResult OnGetJwtToken(Guid id, int draw)
        {
            var list = _sysUserJwtService.GetLastUserJwt(id);
            DatatableModel <Sys_UserJwtMapping> data = new DatatableModel <Sys_UserJwtMapping>(list);

            data.draw = draw;
            return(Json(data));
        }
        /// <summary>
        /// 获取操作的最新记录
        /// </summary>
        /// <param name="id"></param>
        public IActionResult OnGetActivityLog(Guid id, int draw)
        {
            var list = _activityLogService.GetLastUserActivityLogs(id);
            DatatableModel <Sys_ActivityLogMapping> data = new DatatableModel <Sys_ActivityLogMapping>(list);

            data.draw = draw;
            return(Json(data));
        }
        /// <summary>
        /// 获取最新的登陆记录
        /// </summary>
        /// <param name="id"></param>
        public IActionResult OnGetLoginLog(Guid id, int draw)
        {
            var list = _sysUserLoginService.GetLastUserLogins(id);
            DatatableModel <Sys_UserLoginMapping> data = new DatatableModel <Sys_UserLoginMapping>(list);

            data.draw = draw;
            return(Json(data));
        }
Beispiel #7
0
        private List <InvitationCompanyModel> GetInvitationsCompany(DatatableModel dt, InvitationCompanyModel filters)
        {
            filters.CompanyId = UserCompanyId;
            InvitationCompanyServices service = new InvitationCompanyServices();
            PagerModel pager = dt.ToPager();

            return(service.Get(pager, filters));
        }
Beispiel #8
0
        public ActionResult Delete(int id)
        {
            try
            {
                InvitationCompanyModel filters = new InvitationCompanyModel()
                {
                    CompanyId = UserCompanyId
                };
                DatatableModel dt = new DatatableModel()
                {
                    iColumns       = 5,
                    iDisplayLength = 10,
                    iDisplayStart  = 0,
                    iSortCol_0     = 3,
                    iSortingCols   = 1,
                    iTotalRecords  = 0,
                    sSearch        = null
                };
                var invitationsC = GetInvitationsCompany(dt, filters);
                if (invitationsC != null && invitationsC.Count() > 0)
                {
                    return(Json(new RequestResult <object>()
                    {
                        Status = Status.Warning, Message = localResource.txt_company_has_invitation
                    }));
                }

                CompanyServices cs = new CompanyServices();
                CompanyModel    cm = new CompanyModel()
                {
                    CompanyId = id,
                };
                if (cs.HasProjectsVesselsCompany(cm))
                {
                    return(Json(new RequestResult <object>()
                    {
                        Status = Status.Warning, Message = localResource.txt_company_has_vp
                    }));
                }

                var result = cs.RemoveCompany(cm, UserPerson);
                UserCompanyId = null;
                if (result.Status != Status.Success)
                {
                    throw new Exception(string.Format("{0}: {1}", localResource.txt_company_error_delete, result.Message));
                }
                return(Json(result));
            }
            catch (Exception ex)
            {
                Response.StatusCode        = (int)HttpStatusCode.BadRequest;
                Response.StatusDescription = ex.Message;

                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #9
0
        public JsonResult List(DatatableModel dt, VesselModel filters)
        {
            VesselServices services = new VesselServices();
            PagerModel     pager    = dt.ToPager();

            filters.Company.CompanyId = SessionWeb.User.CompanyId;
            var collection = services.Get(pager, filters);

            return(Json(new
            {
                status = UI.Status.Success,
                sEcho = dt.sEcho,
                iTotalRecords = pager.TotalRecords,
                iTotalDisplayRecords = pager.TotalRecords,
                aaData = collection
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        public JsonResult GetTable(DatatableModel dt, AlertModel filters)
        {
            filters.To = SessionWeb.User.PersonId;
            AlertServices services = new AlertServices();
            PagerModel    pager    = dt.ToPager();

            filters.Body = dt.sSearch;

            var collection = services.Get(pager, filters);

            return(Json(new
            {
                status = UI.Status.Success,
                sEcho = dt.sEcho,
                iTotalRecords = pager.TotalRecords,
                iTotalDisplayRecords = pager.TotalRecords,
                aaData = collection
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetItems(DatatableData <ProductViewModel> datatableRequest, int?categoryId)
        {
            var imgPath  = Constants.ImagePath + "/";
            var entities = _productService.GetAll().Where(a => a.Status == (int)Constants.EnumProductStatus.Stocking);

            if (categoryId.HasValue && categoryId > 0)
            {
                entities = entities.Where(a => a.CategoryId == categoryId.Value || a.Category.ParentId == categoryId);
            }
            var models = entities.Select(a => new ProductViewModel()
            {
                Id          = a.Id,
                Price       = a.Price,
                ProductName = a.Name,
                Image       = a.Images.Any() ?
                              a.Images.Any(x => x.Main == true) ?
                              imgPath + a.Images.FirstOrDefault(x => x.Main == true).Name : imgPath + a.Images.FirstOrDefault().Name :
                              null
            }).OrderBy(a => a.Price);

            return(Json(DatatableModel.Refresh(models, datatableRequest.Size, datatableRequest.Index)));
        }
Beispiel #12
0
        private bool HasInvitation(string email, int?companyId)
        {
            InvitationCompanyModel filters = new InvitationCompanyModel()
            {
                Email = email, CompanyId = companyId
            };
            DatatableModel dt = new DatatableModel()
            {
                iColumns       = 5,
                iDisplayLength = 10,
                iDisplayStart  = 0,
                iSortCol_0     = 3,
                iSortingCols   = 1,
                iTotalRecords  = 0,
                sSearch        = email
            };
            InvitationCompanyServices service = new InvitationCompanyServices();
            PagerModel pager      = dt.ToPager();
            var        collection = service.Get(pager, filters).FirstOrDefault();

            HasRejectedInvitation = (collection != null && collection.Status == 2);
            return(collection != null);
        }
Beispiel #13
0
        public ActionResult GetInvitation(DatatableModel dt, InvitationCompanyModel filters)
        {
            try
            {
                PagerModel pager      = dt.ToPager();
                var        collection = GetInvitationsCompany(dt, filters);

                return(Json(new
                {
                    status = UI.Status.Success,
                    sEcho = dt.sEcho,
                    iTotalRecords = pager.TotalRecords,
                    iTotalDisplayRecords = pager.TotalRecords,
                    aaData = collection
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Response.StatusCode        = (int)HttpStatusCode.BadRequest;
                Response.StatusDescription = ex.Message;

                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #14
0
 public IDataTableHelper Initiate(string searchEndpoint)
 {
     model = new DatatableModel(searchEndpoint);
     return(this);
 }