public IActionResult Update(CustomsDeclarationModel model)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.opsCustomClearance);
            var          code  = CheckForbitUpdate(_user.UserMenuPermission.Write);

            if (code == 403)
            {
                return(Forbid());
            }
            var existedMessage = CheckExist(model, model.Id);

            if (existedMessage != null)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = existedMessage
                }));
            }
            var          hs      = customsDeclarationService.Update(model, x => x.Id == model.Id);
            var          message = HandleError.GetMessage(hs, Crud.Update);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        public IQueryable <TariffViewModel> Paging(TariffCriteria criteria, int page, int size, out int rowsCount)
        {
            ICurrentUser _user       = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingTariff);
            var          rangeSearch = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.List);

            if (rangeSearch == PermissionRange.None)
            {
                rowsCount = 0;
                return(null);
            }

            List <TariffViewModel> results = null;
            // var list = Query(criteria);
            IQueryable <TariffViewModel> list = QueryPermission(criteria, rangeSearch);

            if (list == null)
            {
                rowsCount = 0;
                return(null);
            }
            list      = list.OrderByDescending(x => x.DatetimeModified);
            rowsCount = list.ToList().Count;
            if (size > 1)
            {
                if (page < 1)
                {
                    page = 1;
                }
                results = list.Skip((page - 1) * size).Take(size).ToList();
            }
            return(results.AsQueryable());
        }
        public IQueryable <sp_GetCatPlace> QueryExport(CatPlaceCriteria criteria)
        {
            IQueryable <sp_GetCatPlace> data = null;

            if (criteria.PlaceType == CatPlaceTypeEnum.Warehouse)
            {
                ICurrentUser _user       = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catWarehouse);
                var          rangeSearch = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.List);
                if (rangeSearch == PermissionRange.None)
                {
                    return(null);
                }
                data = QueryByPermission(criteria, rangeSearch);
            }
            else if (criteria.PlaceType == CatPlaceTypeEnum.Port)
            {
                ICurrentUser _user       = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catPortindex);
                var          rangeSearch = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.List);
                if (rangeSearch == PermissionRange.None)
                {
                    return(null);
                }
                data = QueryByPermission(criteria, rangeSearch);
            }
            else
            {
                data = Query(criteria);
            }

            return(data);
        }
        public SetTariffModel GetTariffById(Guid tariffId)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingTariff);
            var          permissionRangeWrite  = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);
            var          permissionRangeDelete = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Delete);


            var tariff = DataContext.Get(x => x.Id == tariffId).FirstOrDefault();
            var data   = mapper.Map <SetTariffModel>(tariff);

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = data.UserCreated,
                CompanyId    = data.CompanyId,
                DepartmentId = data.DepartmentId,
                OfficeId     = data.OfficeId,
                GroupId      = data.GroupId
            };

            data.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
                AllowDelete = PermissionExtention.GetPermissionDetail(permissionRangeDelete, baseModel, currentUser),
            };

            data.UserCreatedName   = userRepository.Get(x => x.Id == data.UserCreated).FirstOrDefault()?.Username;
            data.UserModifieddName = userRepository.Get(x => x.Id == data.UserModified).FirstOrDefault()?.Username;

            return(data);
        }
        public IActionResult Delete(int id)
        {
            PermissionRange permissionRange;
            ICurrentUser    _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingEcusConnection);

            permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Delete);
            bool isAllowDelete = ecusConnectionService.CheckAllowPermissionAction(id, permissionRange);

            if (isAllowDelete == false)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            ChangeTrackerHelper.currentUser = currentUser.UserID;
            var          hs      = ecusConnectionService.Delete(x => x.Id == id);
            var          message = HandleError.GetMessage(hs, Crud.Delete);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Beispiel #6
0
        public CatChargeAddOrUpdateModel GetChargeById(Guid id)
        {
            CatChargeAddOrUpdateModel returnCharge = new CatChargeAddOrUpdateModel();
            var charge            = DataContext.Get(x => x.Id == id).FirstOrDefault();
            var listChargeDefault = chargeDefaultRepository.Get(x => x.ChargeId == id).ToList();

            returnCharge.Charge = charge;

            // Update permission
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catCharge);
            var          permissionRangeWrite = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = returnCharge.Charge.UserCreated,
                CompanyId    = returnCharge.Charge.CompanyId,
                DepartmentId = returnCharge.Charge.DepartmentId,
                OfficeId     = returnCharge.Charge.OfficeId,
                GroupId      = returnCharge.Charge.GroupId
            };

            returnCharge.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
            };

            returnCharge.ListChargeDefaultAccount = listChargeDefault;

            return(returnCharge);
        }
Beispiel #7
0
        public IQueryable <SetEcusConnectionModel> Paging(SetEcusConnectionCriteria criteria, int pageNumber, int pageSize, out int totalItems)
        {
            ICurrentUser _user       = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingEcusConnection);
            var          rangeSearch = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.List);

            if (rangeSearch == PermissionRange.None)
            {
                totalItems = 0;
                return(null);
            }

            IQueryable <SetEcusConnectionModel> list = QueryPermission(criteria, rangeSearch);

            if (list == null)
            {
                totalItems = 0;
                return(null);
            }
            totalItems = list.Count();
            if (pageSize > 1)
            {
                if (pageNumber < 1)
                {
                    pageNumber = 1;
                }
                list = list.Skip((pageNumber - 1) * pageSize).Take(pageSize).OrderByDescending(x => x.DatetimeModified);
            }
            return(list);
        }
        public IActionResult GetTariff(Guid tariffId)
        {
            PermissionRange permissionRange;
            ICurrentUser    _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingTariff);

            permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Detail);
            bool isAllowDelete = tariffService.CheckAllowPermissionAction(tariffId, permissionRange);

            if (isAllowDelete == false)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            var result = new TariffModel();

            result.setTariff        = tariffService.GetTariffById(tariffId);
            result.setTariffDetails = tariffService.GetListTariffDetailByTariffId(tariffId)?.OrderBy(x => x.DatetimeCreated).ToList();
            if (result == null)
            {
                return(Ok(new ResultHandle {
                    Status = false, Message = "Không tìm thấy Tariff", Data = result
                }));
            }
            else
            {
                return(Ok(new ResultHandle {
                    Status = true, Message = "Success", Data = result
                }));
            }
        }
        public IActionResult CheckAllowConvertJob([FromBody] List <OpsTransactionClearanceModel> list)
        {
            currentUser = PermissionExtention.GetUserMenuPermission(currentUser, Menu.opsCustomClearance);
            var          hs      = transactionService.CheckAllowConvertJob(list);
            var          message = HandleError.GetMessage(hs, Crud.Update);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = message
            };

            return(Ok(result));
        }
        public IActionResult CheckPermission(int id)
        {
            ICurrentUser _user      = PermissionExtention.GetUserMenuPermission(currentUser, Menu.opsCustomClearance);
            var          statusCode = customsDeclarationService.CheckDetailPermission(id);

            if (statusCode == 403)
            {
                return(Ok(false));
            }
            return(Ok(true));
        }
        public int CheckDeletePermission(string id)
        {
            var          detail          = Get(x => x.Id == id).FirstOrDefault();
            var          salemans        = salemanRepository.Get(x => x.PartnerId == id).ToList();
            ICurrentUser _user           = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catPartnerdata);//Set default
            var          permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Delete);
            int          code            = GetPermissionToDelete(new ModelUpdate {
                GroupId = detail.GroupId, OfficeId = detail.OfficeId, CompanyId = detail.CompanyId, DepartmentId = detail.DepartmentId, UserCreator = detail.UserCreated, Salemans = salemans, PartnerGroup = detail.PartnerGroup
            }, permissionRange);

            return(code);
        }
Beispiel #12
0
        public IActionResult CheckAllowDelete(Guid id)
        {
            var charge = catChargeService.First(x => x.Id == id);

            if (charge == null)
            {
                return(Ok(false));
            }
            ICurrentUser    _user           = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catCharge);
            PermissionRange permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Delete);

            return(Ok(catChargeService.CheckAllowPermissionAction(id, permissionRange)));
        }
Beispiel #13
0
        public IQueryable <CatChargeModel> QueryExport(CatChargeCriteria criteria)
        {
            IQueryable <CatChargeModel> data = null;

            ICurrentUser _user       = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catCharge);
            var          rangeSearch = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.List);

            if (rangeSearch == PermissionRange.None)
            {
                return(data);
            }
            data = QueryByPermission(criteria, rangeSearch);
            return(data);
        }
        public IActionResult Update(SetEcusConnectionModel model)
        {
            PermissionRange permissionRange;
            ICurrentUser    _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingEcusConnection);

            permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Write);

            if (permissionRange == PermissionRange.None)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            bool code = ecusConnectionService.CheckAllowPermissionAction(model.Id, permissionRange);

            if (code == false)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            var existedMessage = CheckExist(model);

            if (existedMessage != null)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = existedMessage
                }));
            }

            model.DatetimeModified = DateTime.Now;
            model.UserModified     = currentUser.UserID;
            model.GroupId          = currentUser.GroupId;
            model.DepartmentId     = currentUser.DepartmentId;
            model.OfficeId         = currentUser.OfficeID;
            model.CompanyId        = currentUser.CompanyID;
            var          hs      = ecusConnectionService.Update(model, x => x.Id == model.Id);
            var          message = HandleError.GetMessage(hs, Crud.Update);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        public List <CatPlaceViewModel> Paging(CatPlaceCriteria criteria, int page, int size, out int rowsCount)
        {
            IQueryable <sp_GetCatPlace> data    = null;
            List <CatPlaceViewModel>    results = null;

            if (criteria.PlaceType == CatPlaceTypeEnum.Warehouse)
            {
                ICurrentUser _user       = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catWarehouse);
                var          rangeSearch = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.List);
                if (rangeSearch == PermissionRange.None)
                {
                    rowsCount = 0;
                    return(null);
                }
                data = QueryByPermission(criteria, rangeSearch);
            }
            else if (criteria.PlaceType == CatPlaceTypeEnum.Port)
            {
                ICurrentUser _user       = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catPortindex);
                var          rangeSearch = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.List);
                if (rangeSearch == PermissionRange.None)
                {
                    rowsCount = 0;
                    return(null);
                }
                data = QueryByPermission(criteria, rangeSearch);
            }
            else
            {
                data = Query(criteria);
            }

            rowsCount = data.Select(x => x.ID).Count();
            if (rowsCount == 0)
            {
                return(results);
            }
            if (size > 1)
            {
                data = data.OrderByDescending(x => x.DatetimeModified);
                if (page < 1)
                {
                    page = 1;
                }
                data = data.Skip((page - 1) * size).Take(size);
            }
            results = GetCulturalData(data).ToList();
            return(results);
        }
        public override HandleState Add(CatPartnerModel entity)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catPartnerdata);//Set default
            var          permissionRangeWrite = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Write);

            if (permissionRangeWrite == PermissionRange.None)
            {
                return(new HandleState(403, ""));
            }
            var partner = mapper.Map <CatPartner>(entity);

            partner.DatetimeCreated  = DateTime.Now;
            partner.DatetimeModified = DateTime.Now;
            partner.UserCreated      = partner.UserModified = currentUser.UserID;
            partner.Active           = true;
            partner.GroupId          = currentUser.GroupId;
            partner.DepartmentId     = currentUser.DepartmentId;
            partner.OfficeId         = currentUser.OfficeID;
            partner.CompanyId        = currentUser.CompanyID;
            var hs = DataContext.Add(partner);

            if (hs.Success)
            {
                if (entity.SaleMans.Count() > 0)
                {
                    var salemans = mapper.Map <List <CatSaleman> >(entity.SaleMans);
                    salemans.ForEach(x =>
                    {
                        x.Id          = Guid.NewGuid();
                        x.PartnerId   = partner.Id;
                        x.CreateDate  = DateTime.Now;
                        x.UserCreated = currentUser.UserID;
                        //x.CompanyId = currentUser.CompanyID;
                        //x.OfficeId = currentUser.OfficeID;
                        //x.GroupId = currentUser.GroupId;
                        //x.DepartmentId = currentUser.DepartmentId;
                    });
                    partner.SalePersonId = salemans.FirstOrDefault().SaleManId.ToString();
                    DataContext.Update(partner, x => x.Id == partner.Id);
                    salemanRepository.Add(salemans);
                }
                DataContext.SubmitChanges();
                salemanRepository.SubmitChanges();
                ClearCache();
                Get();
                SendMail.Send("Confirm Add Partner", webUrl.Value.Url.ToString() + "/en/#/home/catalogue/partner-data/detail/" + entity.Id, "*****@*****.**", null, null);
            }
            return(hs);
        }
        public IActionResult UpdateTariff(TariffModel model)
        {
            PermissionRange permissionRange;
            ICurrentUser    _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingTariff);

            permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Write);

            if (permissionRange == PermissionRange.None)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            bool code = tariffService.CheckAllowPermissionAction(model.setTariff.Id, permissionRange);

            if (code == false)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var checkData = tariffService.CheckExistsDataTariff(model);

            if (!checkData.Success)
            {
                return(Ok(new ResultHandle {
                    Status = checkData.Success, Message = checkData.Exception.Message.ToString(), Data = checkData.Code
                }));
            }

            model.setTariff.UserModified = currentUser.UserID;
            var hs = tariffService.UpdateTariff(model);

            var message = HandleError.GetMessage(hs, Crud.Update);

            ResultHandle result = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value, Data = model
            };

            return(Ok(result));
        }
        public IActionResult CheckAllowDelete(Guid id)
        {
            PermissionRange permissionRange;
            ICurrentUser    _user  = null;
            var             result = new TariffModel();

            result.setTariff = tariffService.GetTariffById(id);
            if (result.setTariff == null)
            {
                return(Ok(false));
            }
            _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingTariff);

            permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Delete);
            return(Ok(tariffService.CheckAllowPermissionAction(id, permissionRange)));
        }
        public IActionResult CheckAllowDetail(int id)
        {
            PermissionRange permissionRange;
            ICurrentUser    _user = null;

            SetEcusConnectionModel ecus = ecusConnectionService.Get(x => x.Id == id).FirstOrDefault();

            if (ecus == null)
            {
                return(Ok(false));
            }
            _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingEcusConnection);

            permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Detail);
            return(Ok(ecusConnectionService.CheckAllowPermissionAction(id, permissionRange)));
        }
        public CatPlaceModel GetDetail(Guid id)
        {
            ICurrentUser _user = null;
            CatPlace     data  = DataContext.First(x => x.Id == id);

            if (data == null)
            {
                return(null);
            }

            CatPlaceModel result = mapper.Map <CatPlaceModel>(data);

            if (data.PlaceTypeId == CatPlaceTypeEnum.Warehouse.ToString())
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catWarehouse);
            }
            if (data.PlaceTypeId == CatPlaceTypeEnum.Port.ToString())
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catPortindex);
            }
            if (data.PlaceTypeId == CatPlaceTypeEnum.Province.ToString() ||
                data.PlaceTypeId == CatPlaceTypeEnum.District.ToString() ||
                data.PlaceTypeId == CatPlaceTypeEnum.Ward.ToString())
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catLocation);
            }

            var permissionRangeWrite = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = result.UserCreated,
                CompanyId    = result.CompanyId,
                DepartmentId = result.DepartmentId,
                OfficeId     = result.OfficeId,
                GroupId      = result.GroupId
            };

            result.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
            };

            return(result);
        }
        public CatPartnerModel GetDetail(string id)
        {
            var          queryDetail           = Get(x => x.Id == id).FirstOrDefault();
            var          salemans              = salemanRepository.Get(x => x.PartnerId == id).ToList();
            ICurrentUser _user                 = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catPartnerdata);//Set default
            var          permissionRangeWrite  = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Write);
            var          permissionRangeDelete = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Delete);
            int          checkDelete           = GetPermissionToDelete(new ModelUpdate {
                GroupId = queryDetail.GroupId, OfficeId = queryDetail.OfficeId, CompanyId = queryDetail.CompanyId, UserCreator = queryDetail.UserCreated, Salemans = salemans, PartnerGroup = queryDetail.PartnerGroup
            }, permissionRangeDelete);

            queryDetail.Permission = new PermissionAllowBase
            {
                AllowUpdate = GetPermissionDetail(permissionRangeWrite, salemans, queryDetail),
                AllowDelete = checkDelete == 403 ? false : true
            };
            return(queryDetail);
        }
        public static ICurrentUser GetUserMenuPermissionTransaction(string transactionType, ICurrentUser currentUser)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docSeaFCLImport);//Set default

            if (transactionType == TermData.InlandTrucking)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docInlandTrucking);
            }
            else if (transactionType == TermData.AirExport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docAirExport);
            }
            else if (transactionType == TermData.AirImport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docAirImport);
            }
            else if (transactionType == TermData.SeaConsolExport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docSeaConsolExport);
            }
            else if (transactionType == TermData.SeaConsolImport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docSeaConsolImport);
            }
            else if (transactionType == TermData.SeaFCLExport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docSeaFCLExport);
            }
            else if (transactionType == TermData.SeaFCLImport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docSeaFCLImport);
            }
            else if (transactionType == TermData.SeaLCLExport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docSeaLCLExport);
            }
            else if (transactionType == TermData.SeaLCLImport)
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.docSeaLCLImport);
            }

            return(_user);
        }
        public IActionResult Delete(Guid id)
        {
            PermissionRange permissionRange;
            ICurrentUser    _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingTariff);

            permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Delete);
            bool isAllowDelete = tariffService.CheckAllowPermissionAction(id, permissionRange);

            if (isAllowDelete == false)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }
            //Check exists tariff & status tariff
            var checkStatus = tariffService.Get(x => x.Id == id).FirstOrDefault();

            if (checkStatus == null)
            {
                return(Ok(new ResultHandle {
                    Status = false, Message = "Not found tariff"
                }));
            }
            else
            {
                if (checkStatus.Status == true)
                {
                    return(Ok(new ResultHandle {
                        Status = false, Message = "Not allowed delete tariff"
                    }));
                }
            }

            var          hs      = tariffService.DeleteTariff(id);
            var          message = HandleError.GetMessage(hs, Crud.Delete);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            return(Ok(result));
        }
        public IActionResult ImportClearancesFromEcus()
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.opsCustomClearance);
            var          code  = CheckForbitUpdate(_user.UserMenuPermission.Write);

            if (code == 403)
            {
                return(Forbid());
            }
            var          hs      = customsDeclarationService.ImportClearancesFromEcus();
            var          message = HandleError.GetMessage(hs, Crud.Update);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = message
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        public IActionResult ConvertExistedClearancesToJobs([FromBody] List <OpsTransactionClearanceModel> list)
        {
            currentUser = PermissionExtention.GetUserMenuPermission(currentUser, Menu.opsCustomClearance);
            var permissionRange = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);

            if (permissionRange == PermissionRange.None)
            {
                return(Forbid());
            }
            HandleState  hs      = transactionService.ConvertExistedClearancesToJobs(list);
            var          message = HandleError.GetMessage(hs, Crud.Insert);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = message
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        public IActionResult Import([FromBody] List <CustomsDeclarationModel> data)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.opsCustomClearance);
            var          code  = CheckForbitUpdate(_user.UserMenuPermission.Write);

            if (code == 403)
            {
                return(Forbid());
            }
            var result = customsDeclarationService.Import(data);

            if (result != null)
            {
                return(Ok(result));
            }
            else
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.FILE_NOT_FOUND].Value
                }));
            }
        }
        public IActionResult AddNew(CustomsDeclarationModel model)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.opsCustomClearance);
            var          code  = CheckForbitUpdate(_user.UserMenuPermission.Write);

            if (code == 403)
            {
                return(Forbid());
            }
            var existedMessage = CheckExist(model, model.Id);

            if (existedMessage != null)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = existedMessage
                }));
            }
            model.DatetimeCreated  = DateTime.Now;
            model.DatetimeModified = DateTime.Now;
            model.UserCreated      = model.UserModified = currentUser.UserID;
            model.Source           = OperationConstants.FromEFMS;
            model.GroupId          = currentUser.GroupId;
            model.DepartmentId     = currentUser.DepartmentId;
            model.OfficeId         = currentUser.OfficeID;
            model.CompanyId        = currentUser.CompanyID;
            var          hs      = customsDeclarationService.Add(model);
            var          message = HandleError.GetMessage(hs, Crud.Insert);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Beispiel #28
0
        public SetEcusConnectionModel GetConnectionDetails(int id)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingEcusConnection);
            var          permissionRangeWrite = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);

            var data = Get(x => x.Id == id);

            if (data == null)
            {
                return(null);
            }

            var result = data.FirstOrDefault();

            var users = userRepository.Get();

            result.Username         = users.FirstOrDefault(x => x.Id == result.UserId)?.Username;
            result.UserCreatedName  = users.FirstOrDefault(x => x.Id == result.UserCreated)?.Username;
            result.UserModifiedName = users.FirstOrDefault(x => x.Id == result.UserModified)?.Username;

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = result.UserCreated,
                CompanyId    = result.CompanyId,
                DepartmentId = result.DepartmentId,
                OfficeId     = result.OfficeId,
                GroupId      = result.GroupId
            };

            result.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
            };

            return(result);
        }
Beispiel #29
0
        public IActionResult Update(CatChargeAddOrUpdateModel model)
        {
            ICurrentUser    _user           = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catCharge);
            PermissionRange permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Write);

            if (permissionRange == PermissionRange.None || !catChargeService.CheckAllowPermissionAction(model.Charge.Id, permissionRange))
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var checkExistMessage = CheckExist(model.Charge.Id, model);

            if (checkExistMessage.Length > 0)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = checkExistMessage
                }));
            }
            var          hs      = catChargeService.UpdateCharge(model);
            var          message = HandleError.GetMessage(hs, Crud.Update);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Beispiel #30
0
        public IActionResult Delete(Guid id)
        {
            ICurrentUser    _user           = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catCharge);
            PermissionRange permissionRange = PermissionExtention.GetPermissionRange(_user.UserMenuPermission.Delete);

            if (!catChargeService.CheckAllowPermissionAction(id, permissionRange))
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value
                }));
            }

            var          hs      = catChargeService.DeleteCharge(id);
            var          message = HandleError.GetMessage(hs, Crud.Delete);
            ResultHandle result  = new ResultHandle {
                Status = hs.Success, Message = stringLocalizer[message].Value
            };

            if (!hs.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }