public IHttpActionResult Update(int id, DTO.LoadingPlanMng.LoadingPlan dtoItem)
        {
            Library.DTO.Notification notification;

            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (id > 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanUpdate))
            {
                // edit case
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }
            else if (id == 0 && !fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanCreate))
            {
                // create new case
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            // validation
            if (!Helper.CommonHelper.ValidateDTO <DTO.LoadingPlanMng.LoadingPlan>(dtoItem, out notification))
            {
                return(Ok(new Library.DTO.ReturnData <DTO.LoadingPlanMng.LoadingPlan>()
                {
                    Data = dtoItem, Message = notification
                }));
            }

            // continue processing
            BLL.LoadingPlanMng bll = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            bll.UpdateData(id, ref dtoItem, ControllerContext.GetAuthUserId(), out notification);

            return(Ok(new Library.DTO.ReturnData <DTO.LoadingPlanMng.LoadingPlan>()
            {
                Data = dtoItem, Message = notification
            }));
        }
        public IHttpActionResult QuickSearchLoadingPlan(DTO.Search searchInput)
        {
            // authentication
            Module.Framework.BLL     fwBll = new Module.Framework.BLL();
            BLL.LoadingPlanMng       bll   = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            Library.DTO.Notification notification;
            int totalRows = 0;
            IEnumerable <DTO.LoadingPlanMng.LoadingPlanSearchResult> data = bll.QuickSearchLoadingPlan(ControllerContext.GetAuthUserId(), searchInput.Filters, searchInput.PageSize, searchInput.PageIndex, searchInput.SortedBy, searchInput.SortedDirection, out totalRows, out notification);

            return(Ok(new Library.DTO.ReturnData <IEnumerable <DTO.LoadingPlanMng.LoadingPlanSearchResult> >()
            {
                Data = data, Message = notification, TotalRows = totalRows
            }));
        }
 public IHttpActionResult SetLoadingPlanStatus(int id, bool isConfirmed, bool isLoaded, bool isShipped, int branchID)
 {
     // authentication
     Module.Framework.BLL fwBll = new Module.Framework.BLL();
     if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanApprove))
     {
         return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
     }
     BLL.LoadingPlanMng       bll = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
     Library.DTO.Notification notification;
     bll.SetLoadingPlanStatus(id, ControllerContext.GetAuthUserId(), branchID, isConfirmed, isLoaded, isShipped, out notification);
     return(Ok(new Library.DTO.ReturnData <int>()
     {
         Data = id, Message = notification
     }));
 }
        public IHttpActionResult GetPrinOutHTML(int loadingPlanID)
        {
            //authentication
            Module.Framework.BLL fwBLL = new Module.Framework.BLL();
            if (!fwBLL.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }
            Library.DTO.Notification notification = new Library.DTO.Notification();
            BLL.LoadingPlanMng       bll          = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            object data = bll.GetReportHTML(loadingPlanID, out notification);

            return(Ok(new Library.DTO.ReturnData <object>()
            {
                Data = data, Message = notification
            }));
        }
        public IHttpActionResult GetInitData()
        {
            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanCreate))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            BLL.LoadingPlanMng              bll = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            Library.DTO.Notification        notification;
            DTO.LoadingPlanMng.InitFormData data = bll.GetInitData(ControllerContext.GetAuthUserId(), out notification);

            return(Ok(new Library.DTO.ReturnData <DTO.LoadingPlanMng.InitFormData>()
            {
                Data = data, Message = notification
            }));
        }
        public IHttpActionResult QuicksearchSampleProduct(DTO.Search searchInput)
        {
            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanRead))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            BLL.LoadingPlanMng       bll = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            Library.DTO.Notification notification;
            int totalRows = 0;
            List <DTO.LoadingPlanMng.SampleProductSearchResult> data = bll.QuicksearchSampleProduct(ControllerContext.GetAuthUserId(), searchInput.Filters, searchInput.PageSize, searchInput.PageIndex, searchInput.SortedBy, searchInput.SortedDirection, out totalRows, out notification);

            return(Ok(new Library.DTO.ReturnData <List <DTO.LoadingPlanMng.SampleProductSearchResult> >()
            {
                Data = data, Message = notification, TotalRows = totalRows
            }));
        }
        public IHttpActionResult GetReportData(List <int> loadingPlanIDs, int print_type)
        {
            Library.DTO.Notification notification;

            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            BLL.LoadingPlanMng bll            = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            string             reportFileName = bll.GetReportData(loadingPlanIDs, print_type, ControllerContext.GetAuthUserId(), out notification);

            return(Ok(new Library.DTO.ReturnData <string>()
            {
                Data = reportFileName, Message = notification
            }));
        }
        public IHttpActionResult GetViewData(int id, int fID, int bID, int pID)
        {
            // authentication
            Module.Framework.BLL fwBll = new Module.Framework.BLL();
            if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanRead))
            {
                return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED)));
            }

            BLL.LoadingPlanMng       bll = new BLL.LoadingPlanMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext));
            Library.DTO.Notification notification;
            //if (id > 0)
            //{
            //    fID = bID = pID = 0;
            //}

            DTO.LoadingPlanMng.OverviewData data = bll.GetViewData(id, fID, bID, pID, ControllerContext.GetAuthUserId(), out notification);

            return(Ok(new Library.DTO.ReturnData <DTO.LoadingPlanMng.OverviewData>()
            {
                Data = data, Message = notification
            }));
        }