예제 #1
0
        public OperationResult Create(CreateSlide command)
        {
            var result      = new OperationResult();
            var path        = "Slides";
            var picturePath = _fileUploader.FileUpload(command.Picture, path);

            var slide = new Slide(picturePath, command.PictureTitle, command.PictureAlt, command.Heading, command.Title,
                                  command.Text, command.BtnText, command.Link);

            _slideRepository.Create(slide);
            _slideRepository.SaveChanges();
            return(result.Succeeded());
        }
        public OperationResult Create(CreateProductPicture command)
        {
            var result              = new OperationResult();
            var product             = _productRepository.GetProductWithCategory(command.ProductId);
            var productCategorySlug = product.Category.Slug;
            var productSlug         = product.Slug;
            var picturePath         = $"{productCategorySlug}/{productSlug}";
            var pictureName         = _fileUploader.FileUpload(command.Picture, picturePath);
            var productPicture      = new ProductPicture(pictureName, command.PictureAlt, command.PictureTitle, command.ProductId);

            _productPictureRepository.Create(productPicture);
            _productPictureRepository.SaveChanges();
            return(result.Succeeded());
        }
        public OperationResult Create(CreateProductCategory command)
        {
            var operationResult = new OperationResult();

            if (_productCategoryRepository.Exists(p => p.Name == command.Name))
            {
                return(operationResult.Failed("امکان ثبت رکورد تکراری وجود ندارد."));
            }

            var filename        = _fileUploader.FileUpload(command.Picture, command.Slug);
            var produceCategory = new ProductCategory(command.Name, command.Description, filename, command.PictureAlt,
                                                      command.PictureTitle, command.Keywords, command.MetaDescription, command.Slug.Slugify());

            _productCategoryRepository.Create(produceCategory);
            _productCategoryRepository.SaveChanges();
            return(operationResult.Succeeded());
        }
예제 #4
0
        public OperationResult Register(CreateAccount command)
        {
            var operationResult = new OperationResult();

            if (_accountRepository.Exists(a => a.Username == command.Username || a.Mobile == command.Mobile))
            {
                return(operationResult.Failed(QueryValidationMessage.DuplicateRecord));
            }

            var profilePhoto   = _fileUploader.FileUpload(command.ProfilePhoto, "ProfilePhotos");
            var hashedPassword = _passwordHasher.Hash(command.Password);

            var account = new Account(command.Fullname, command.Username, hashedPassword, command.Mobile, command.RoleId, profilePhoto);

            _accountRepository.Create(account);
            _accountRepository.SaveChanges();
            return(operationResult.Succeeded());
        }
예제 #5
0
        public OperationResult Create(CreateProduct command)
        {
            var operationResult = new OperationResult();

            if (_productRepository.Exists(p => p.Name == command.Name))
            {
                return(operationResult.Failed(QueryValidationMessage.DuplicateRecord));
            }

            var productCategorySlug = _productCategoryRepository.GetSlugBy(command.CategoryId);
            var productSlug         = GenerateSlug.Slugify(command.Slug);
            var picturePath         = $"{productCategorySlug}/{productSlug}";

            var pictureName = _fileUploader.FileUpload(command.Picture, picturePath);

            var product = new Product(command.Name, command.Code, productSlug,
                                      command.MetaDescription, command.Keywords, command.Description, command.ShortDescription, pictureName,
                                      command.PictureAlt, command.PictureTitle, command.CategoryId);

            _productRepository.Create(product);
            _productRepository.SaveChanges();
            return(operationResult.Succeeded());
        }