Beispiel #1
0
        public SubCategory[] GetSubCategories(string filter, Category category)
        {
            CheckHelper.ArgumentNotNull(category, "category");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.GetSubCategoriesByCategory(category, filter)));
        }
Beispiel #2
0
        public Order[] GetOrders(DateTime startDate, DateTime endDate, string filter)
        {
            CheckHelper.ArgumentWithinCondition(startDate <= endDate, "startDate <= endDate");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetOrders(startDate, endDate, filter)));
        }
Beispiel #3
0
        public string Login(string login, string password)
        {
            if (string.IsNullOrWhiteSpace(login) && string.IsNullOrWhiteSpace(password))
            {
                return(@"Не заданы ""Логин"" и ""Пароль""");
            }

            if (string.IsNullOrWhiteSpace(login))
            {
                return(@"Не задан ""Логин""");
            }

            if (string.IsNullOrWhiteSpace(password))
            {
                return(@"Не задан ""Пароль""");
            }

            var securityData =
                new SecurityData
            {
                Login    = login,
                Password = password
            };

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.LogIn(securityData));

            if (string.IsNullOrEmpty(errorMessage))
            {
                _securityData = securityData;
            }

            return(errorMessage);
        }
Beispiel #4
0
        public OrderItem[] GetOrderItems(Order order)
        {
            CheckHelper.ArgumentNotNull(order, "order");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetOrderItems(order)));
        }
Beispiel #5
0
        public void DeletePicture(Picture picture)
        {
            CheckHelper.ArgumentNotNull(picture, "picture");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            IoC.Container.Get <IValidateService>().CheckIsValid(picture);

            APIClientHelper <ImageAPIClient> .Call(c => c.DeletePicture(picture));
        }
Beispiel #6
0
        public Size[] GetSizes(string filter, SubCategory subCategory, Brand brand)
        {
            CheckHelper.ArgumentNotNull(subCategory, "subCategory");
            CheckHelper.ArgumentNotNull(brand, "brand");

            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.GetSizesBySubCategoryAndBrand(subCategory, brand, filter)));
        }
Beispiel #7
0
        public string ResetPassword(User user)
        {
            CheckHelper.ArgumentNotNull(user, "user");
            CheckHelper.ArgumentWithinCondition(user.Id > 0, "user.Id > 0");
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            if (_currentUser.Id == user.Id)
            {
                return("Пользователь не может сбросить себе пароль.");
            }

            return(APIClientHelper <SecurityAPIClient> .Call(c => c.ResetPassword(user)));
        }
Beispiel #8
0
        public string UpdateDistributorTransfer(DistributorTransfer distributorTransfer)
        {
            CheckHelper.ArgumentNotNull(distributorTransfer, "distributorTransfer");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(distributorTransfer);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.UpdateDistributorTransfer(distributorTransfer)));
        }
Beispiel #9
0
        public string UpdateParcel(Parcel parcel)
        {
            CheckHelper.ArgumentNotNull(parcel, "parcel");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(parcel);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.UpdateParcel(parcel)));
        }
Beispiel #10
0
        public string UpdateBrand(Brand brand)
        {
            CheckHelper.ArgumentNotNull(brand, "brand");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(brand);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.UpdateBrand(brand)));
        }
Beispiel #11
0
        public string UpdateSubCategory(SubCategory subCategory)
        {
            CheckHelper.ArgumentNotNull(subCategory, "subCategory");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(subCategory);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.UpdateSubCategory(subCategory)));
        }
Beispiel #12
0
        public string UpdateProduct(DTO.Product product)
        {
            CheckHelper.ArgumentNotNull(product, "product");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            var errors = IoC.Container.Get <IValidateService>().Validate(product);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            return(APIClientHelper <ProductAPIClient> .Call(c => c.UpdateProduct(product)));
        }
Beispiel #13
0
        public Picture UploadPicture(string path)
        {
            CheckHelper.ArgumentNotNullAndNotWhiteSpace(path, "path");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            CheckHelper.WithinCondition(File.Exists(path), string.Format("File {0} does not exist.", path));

            var fileExtension = Path.GetExtension(path);

            CheckHelper.WithinCondition(fileExtension != null && fileExtension.ToUpper() == ".JPG",
                                        string.Format("File {0} is not jpg file.", path));

            var picture = File.ReadAllBytes(path);

            var resizedPicture = ResizePicture(picture);

            return(APIClientHelper <ImageAPIClient> .Call(c => c.UploadPicture(resizedPicture)));
        }
Beispiel #14
0
        public string CreateCategory(Category category)
        {
            CheckHelper.ArgumentNotNull(category, "category");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(category);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdCategory = (Category)category.Clone();

            var errorMessage = APIClientHelper <DictionaryAPIClient> .Call(c => c.CreateCategory(ref createdCategory));

            category.Id = createdCategory.Id;

            return(errorMessage);
        }
Beispiel #15
0
        public string CreateBrand(Brand brand)
        {
            CheckHelper.ArgumentNotNull(brand, "brand");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(brand);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdBrand = (Brand)brand.Clone();

            var errorMessage = APIClientHelper <DictionaryAPIClient> .Call(c => c.CreateBrand(ref createdBrand));

            brand.Id = createdBrand.Id;

            return(errorMessage);
        }
Beispiel #16
0
        public string CreateSize(Size size)
        {
            CheckHelper.ArgumentNotNull(size, "size");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(size);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdSize = (Size)size.Clone();

            var errorMessage = APIClientHelper <DictionaryAPIClient> .Call(c => c.CreateSize(ref createdSize));

            size.Id = createdSize.Id;

            return(errorMessage);
        }
Beispiel #17
0
        public string CreateProductSize(ProductSize productSize)
        {
            CheckHelper.ArgumentNotNull(productSize, "productSize");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            var errors = IoC.Container.Get <IValidateService>().Validate(productSize);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdProductSize = (ProductSize)productSize.Clone();

            var errorMessage = APIClientHelper <ProductAPIClient> .Call(c => c.CreateProductSize(ref createdProductSize));

            productSize.Id = createdProductSize.Id;

            return(errorMessage);
        }
Beispiel #18
0
        public string CreateUser(User user)
        {
            CheckHelper.ArgumentNotNull(user, "user");
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(user);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdUser = (User)user.Clone();

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.CreateUser(ref createdUser));

            user.Id = createdUser.Id;

            return(errorMessage);
        }
Beispiel #19
0
        public string CreateParcel(Parcel parcel)
        {
            CheckHelper.ArgumentNotNull(parcel, "parcel");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(parcel);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdParcel = (Parcel)parcel.Clone();

            var errorMessage = APIClientHelper <DocumentAPIClient> .Call(c => c.CreateParcel(ref createdParcel));

            parcel.Id = createdParcel.Id;

            return(errorMessage);
        }
Beispiel #20
0
        public string CreateOrder(Order order)
        {
            CheckHelper.ArgumentNotNull(order, "order");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(order);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var createdOrder = (Order)order.Clone();

            var errorMessage = APIClientHelper <DocumentAPIClient> .Call(c => c.CreateOrder(ref createdOrder));

            order.Id = createdOrder.Id;

            return(errorMessage);
        }
        public string UpdateSettings(Settings settings)
        {
            CheckHelper.ArgumentNotNull(settings, "settings");
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(settings);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var errorMessage = APIClientHelper <AdministrationAPIClient> .Call(c => c.UpdateSettings(settings));

            if (errorMessage == null)
            {
                _settings = null;
            }

            return(errorMessage);
        }
Beispiel #22
0
        public string UpdateUser(User user)
        {
            CheckHelper.ArgumentNotNull(user, "user");
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            var errors = IoC.Container.Get <IValidateService>().Validate(user);

            if (errors != null)
            {
                return(errors.ToErrorMessage());
            }

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.UpdateUser(user));

            if (errorMessage == null && _currentUser.Id == user.Id)
            {
                _securityData.Login = user.Login;
                _currentUser        = null;
            }

            return(errorMessage);
        }
Beispiel #23
0
        public string ChangePassword(string newPassword, string passwordConfirmation)
        {
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            if (string.IsNullOrWhiteSpace(newPassword) && string.IsNullOrWhiteSpace(passwordConfirmation))
            {
                return(@"Не заданы ""Новый пароль"" и ""Подтверждение пароля""");
            }

            if (string.IsNullOrWhiteSpace(newPassword))
            {
                return(@"Не задан ""Новый пароль""");
            }

            if (string.IsNullOrWhiteSpace(passwordConfirmation))
            {
                return(@"Не задано ""Подтверждение пароля""");
            }

            if (newPassword != passwordConfirmation)
            {
                return(@"""Новый пароль"" и ""Подтверждение пароля"" не совпадают");
            }

            if (!StringValidator.ValidatePassword(newPassword))
            {
                return("Пароль должен иметь длину от 5 до 50 символов.");
            }

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.ChangePassword(newPassword));

            if (string.IsNullOrEmpty(errorMessage))
            {
                _securityData.Password = newPassword;
            }

            return(errorMessage);
        }
Beispiel #24
0
        public ProductSize[] GetProductSizes(string filter)
        {
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            return(APIClientHelper <ProductAPIClient> .Call(c => c.GetProductSizes(filter)));
        }
Beispiel #25
0
        public DTO.Product[] GetProducts(DateTime startDate, DateTime endDate, string filter)
        {
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            return(APIClientHelper <ProductAPIClient> .Call(c => c.GetProductsByDate(startDate, endDate, filter)));
        }
Beispiel #26
0
        public User[] GetUsers(string filter)
        {
            CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn");

            return(APIClientHelper <SecurityAPIClient> .Call(c => c.GetUsers(filter)));
        }
Beispiel #27
0
        public SubCategory[] GetSubCategories(string filter)
        {
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DictionaryAPIClient> .Call(c => c.GetSubCategories(filter)));
        }
Beispiel #28
0
        public DistributorTransfer[] GetDistributorTransfers(User distributor)
        {
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn");

            return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetDistributorTransfers(distributor)));
        }
Beispiel #29
0
        public DistributorReportItem[] GenerateDistributorsReport()
        {
            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");

            return(APIClientHelper <ReportAPIClient> .Call(c => c.GenerateDistributorsReport()));
        }