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))); }
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))); }
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); }
public OrderItem[] GetOrderItems(Order order) { CheckHelper.ArgumentNotNull(order, "order"); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn"); return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetOrderItems(order))); }
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)); }
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))); }
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))); }
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))); }
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))); }
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))); }
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))); }
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))); }
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))); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public ProductSize[] GetProductSizes(string filter) { CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); return(APIClientHelper <ProductAPIClient> .Call(c => c.GetProductSizes(filter))); }
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))); }
public User[] GetUsers(string filter) { CheckHelper.WithinCondition(IsLoggedIn, "IsLoggedIn"); return(APIClientHelper <SecurityAPIClient> .Call(c => c.GetUsers(filter))); }
public SubCategory[] GetSubCategories(string filter) { CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn"); return(APIClientHelper <DictionaryAPIClient> .Call(c => c.GetSubCategories(filter))); }
public DistributorTransfer[] GetDistributorTransfers(User distributor) { CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "SecurityService.IsLoggedIn"); return(APIClientHelper <DocumentAPIClient> .Call(c => c.GetDistributorTransfers(distributor))); }
public DistributorReportItem[] GenerateDistributorsReport() { CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); return(APIClientHelper <ReportAPIClient> .Call(c => c.GenerateDistributorsReport())); }