コード例 #1
0
        public async Task <UpsertBlogOutput> UpsertBlogAsync(UpsertBlogInput input)
        {
            #region Validation

            if (input.Title.IsNullOrEmpty())
            {
                throw new UserFriendlyException("لطفا نام دسته بندی را وارد نمائید !!!");
            }

            #endregion

            var pc = new Blog();

            int?blogId = null;

            if (input.Id == 0)
            {
                if (_blogRepo.GetAll().Any(p => p.Title == input.Title || p.EnTitle == input.EnTitle))
                {
                    throw new UserFriendlyException("این دسته بندی در سیستم موجود می باشد !!!!");
                }

                pc.Title       = input.Title;
                pc.Description = input.Description;


                blogId = _blogRepo.InsertAndGetId(pc);
            }
            else
            {
                pc = _blogRepo.GetAll()
                     .SingleOrDefault(p => p.Id == input.Id);

                if (pc == null)
                {
                    throw new UserFriendlyException("آیتم مورد نظر وجود ندارد ویا حذف شده است !!!");
                }

                blogId = pc.Id;

                _fileDomainService.Delete(SystemConsts.DefaultPathBlog, blogId + ".jpg");


                pc.Title       = input.Title;
                pc.Description = input.Description;
            }
            _fileDomainService.Upload(SystemConsts.DefaultPathBlog, blogId + ".jpg", input.Based64BinaryString);

            pc.Labels        = input.Labels;
            pc.EnDescription = input.EnDescription;
            pc.EnTitle       = input.EnTitle;


            return(new UpsertBlogOutput());
        }
コード例 #2
0
        public async Task <UpsertCertificateOutput> UpsertCertificateAsync(UpsertCertificateInput input)
        {
            #region Validation

            if (input.Name.IsNullOrEmpty())
            {
                throw new UserFriendlyException("لطفا نام  را وارد نمائید !!!");
            }

            #endregion

            var pc = new Certificate();

            int cerId = 0;

            if (input.Id == 0)
            {
                if (_CertificateRepo.GetAll().Any(p => p.Name == input.Name || p.EnName == input.EnName))
                {
                    throw new UserFriendlyException("این موضوع در سیستم موجود می باشد !!!!");
                }

                pc.Name        = input.Name;
                pc.Description = input.Description;


                cerId = _CertificateRepo.InsertAndGetId(pc);
            }
            else
            {
                pc = _CertificateRepo.GetAll()
                     .SingleOrDefault(p => p.Id == input.Id);

                if (pc == null)
                {
                    throw new UserFriendlyException("آیتم مورد نظر وجود ندارد ویا حذف شده است !!!");
                }

                cerId = pc.Id;
                _fileDomainService.Delete(SystemConsts.DefaultPathCertificate, cerId + ".jpg");

                pc.Name        = input.Name;
                pc.Description = input.Description;
            }

            _fileDomainService.Upload(SystemConsts.DefaultPathCertificate, cerId + ".jpg", input.Based64BinaryString);
            pc.Labels        = input.Labels;
            pc.EnDescription = input.EnDescription;
            pc.EnName        = input.EnName;


            return(new UpsertCertificateOutput());
        }
コード例 #3
0
        public async Task <UpsertProductOutput> UpsertProductAsync(UpsertProductInput input)
        {
            #region Validation

            if (input.Name.IsNullOrEmpty())
            {
                throw new UserFriendlyException("لطفا نام کالا را وارد نمائید !!!");
            }
            if (input.ProductCategoryId == 0)
            {
                throw new UserFriendlyException("لطفا دسته بندی را وارد نمائید !!!");
            }

            if (input.Price == 0)
            {
                throw new UserFriendlyException("لطفا قیمت را وارد نمائید !!!");
            }
            if (input.Count == 0)
            {
                throw new UserFriendlyException("لطفا تعداد را وارد نمائید !!!");
            }
            #endregion

            var pc = new Product();

            int?productId = null;

            if (input.Id == 0)
            {
                if (_productRepo.GetAll().Any(p => p.Name == input.Name & p.ProductCategoryId == input.ProductCategoryId))
                {
                    throw new UserFriendlyException("این محصول در سیستم موجود می باشد !!!!");
                }

                pc.Name              = input.Name;
                pc.Description       = input.Description;
                pc.Count             = input.Count;
                pc.Labels            = input.Labels;
                pc.Price             = input.Price;
                pc.ProductCategoryId = input.ProductCategoryId;
                pc.SendPriceInRange  = input.SendPriceInRage;
                pc.SendPriceOutRange = input.SendPriceOutRage;
                pc.Weight            = input.Weight;
                pc.Unit              = input.Unit;

                productId = _productRepo.InsertAndGetId(pc);
            }
            else
            {
                pc = _productRepo.GetAll()
                     .SingleOrDefault(p => p.Id == input.Id);

                if (pc == null)
                {
                    throw new UserFriendlyException("آیتم مورد نظر وجود ندارد ویا حذف شده است !!!");
                }

                productId = pc.Id;
                _fileDomainService.Delete(SystemConsts.DefaultPathProduct, productId + ".jpg");

                pc.Name              = input.Name;
                pc.Description       = input.Description;
                pc.Count             = input.Count;
                pc.Labels            = input.Labels;
                pc.Price             = input.Price;
                pc.ProductCategoryId = input.ProductCategoryId;
                pc.SendPriceInRange  = input.SendPriceInRage;
                pc.SendPriceOutRange = input.SendPriceOutRage;
                pc.Weight            = input.Weight;
                pc.Unit              = input.Unit;
            }

            _fileDomainService.Upload(SystemConsts.DefaultPathProduct, productId + ".jpg", input.Based64BinaryString);

            pc.EnName        = input.EnName;
            pc.EnDescription = input.EnDescription;


            return(new UpsertProductOutput());
        }