コード例 #1
0
        public HttpResponseMessage Put([FromBody] Models.product_category product_category)
        {
            try
            {
                Models.product_category updateProductCategory = new Models.product_category
                {
                    product_category_id   = product_category.product_category_id,
                    product_category_name = product_category.product_category_name,
                    product_category_code = product_category.product_category_code
                };

                productCategoryRepository.EditProductCategory(updateProductCategory);


                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "success", msg = "Product Category update successfully"
                }, formatter));
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
コード例 #2
0
 public bool EditProductCategory_S(ProductCategory ProCategory)
 {
     if (_repository.EditProductCategory(ProCategory))
     {
         return(true);
     }
     return(false);
 }
コード例 #3
0
        public ActionResult DeleteProductCategory(Int64 Id)
        {
            ResponseModel _response = new ResponseModel();
            var           details   = _productCategoryRepository.FindBy(x => x.ProductCategoryId == Id).FirstOrDefault();

            details.IsDeleted    = true;
            details.ModifiedDate = DateTime.Now;
            details.ModifiedBy   = UserAuthenticate.UserId;
            bool IsTrue = _productCategoryRepository.EditProductCategory(details);

            if (IsTrue)
            {
                _response.Type    = "success";
                _response.Message = "Company deleted successfully";
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Somehing went wrong";
            }
            return(Json(_response, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public HttpResponseMessage EditProductCategory(ProductCategoryModel productCategoryModel)
        {
            ResponseModel _response    = new ResponseModel();
            var           _getCategory = _productCategoryRepository.FindBy(x => x.ProductCategoryId != productCategoryModel.ProductCategoryId && x.ProductCategoryName.Trim().ToLower() == productCategoryModel.ProductCategoryName.Trim().ToLower() && x.Status == (int)Status.Active && x.IsDeleted == false).FirstOrDefault();

            if (_getCategory != null)
            {
                _response.Type    = "error";
                _response.Message = "Company already Exist";
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }

            var _productCategory = _productCategoryRepository.FindBy(x => x.ProductCategoryId == productCategoryModel.ProductCategoryId).FirstOrDefault();

            _productCategory.ProductCategoryId   = productCategoryModel.ProductCategoryId;
            _productCategory.ProductCategoryName = productCategoryModel.ProductCategoryName;
            _productCategory.ModifiedBy          = productCategoryModel.ModifiedBy;
            _productCategory.ModifiedDate        = productCategoryModel.ModifiedDate;

            // var model = Mapper.Map<ProductCategoryModel, ProductCategory>(productCategoryModel);
            var IsResponse = _productCategoryRepository.EditProductCategory(_productCategory);

            if (IsResponse)
            {
                // For Uploading image ----
                if (productCategoryModel.DocProductCategory != null)
                {
                    UploadDocumentModel UploadDocument = new UploadDocumentModel();
                    UploadDocument.documents    = new List <DocumentModel>();
                    UploadDocument.ImageSize    = 250;
                    UploadDocument.ImageQuality = 250;
                    UploadDocument.documents.Add(productCategoryModel.DocProductCategory);
                    List <string> uploadedFileName = SavePicture(UploadDocument);
                    if (uploadedFileName.Count > 0)
                    {
                        if (_productCategory != null)
                        {
                            // delete exiting images
                            string ImgPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/UploadImg/" + _productCategory.ProductCategoryImagePath);
                            if (System.IO.File.Exists(ImgPath))
                            {
                                System.IO.File.Delete(ImgPath);
                            }
                            string ImgOriginalPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/UploadImg/" + "Original_" + _productCategory.ProductCategoryImagePath);
                            if (System.IO.File.Exists(ImgOriginalPath))
                            {
                                System.IO.File.Delete(ImgOriginalPath);
                            }
                            string TImgPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/UploadImg/" + "T" + _productCategory.ProductCategoryImagePath);
                            if (System.IO.File.Exists(TImgPath))
                            {
                                System.IO.File.Delete(TImgPath);
                            }
                            //------------------------------
                            _productCategory.ProductCategoryImagePath = uploadedFileName[0].ToString();
                            _productCategoryRepository.Update(_productCategory);
                            _productCategoryRepository.SaveChanges();
                        }
                    }
                }
                _response.Type    = "success";
                _response.Message = "Company updated successfully";
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Something went wrong";
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }