Пример #1
0
 public long AddProductCategory(product_category product_category)
 {
     try
     {
         product_category insert_product_category = new product_category
         {
             product_category_name = product_category.product_category_name,
             product_category_code = product_category.product_category_code,
             //created_by =
             created_date = DateTime.Now,
             //updated_by =
             updated_date = DateTime.Now,
             is_active    = true,
             is_deleted   = false,
         };
         _entities.product_category.Add(insert_product_category);
         _entities.SaveChanges();
         long last_insert_id = insert_product_category.product_category_id;
         return(last_insert_id);
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
Пример #2
0
        /// <summary>
        /// Save Category details in database
        /// </summary>
        /// <param name="categoryDetails">Category details to be saved</param>
        /// <returns>returns boolean value indicating if the records are saved in database</returns>
        bool ICategoryService.SaveCategoryDetails(ProductCategoryDTO categoryDetails)
        {
            product_category categoryEntity = new product_category();

            ObjectMapper.Map(categoryDetails, categoryEntity);
            return(CategoryRepository.Save(categoryEntity));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            product_category product_category = db.product_category.Find(id);

            db.product_category.Remove(product_category);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "category_id,name")] product_category product_category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product_category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product_category));
 }
Пример #5
0
        public ActionResult Create([Bind(Include = "category_id,name")] product_category product_category)
        {
            if (ModelState.IsValid)
            {
                db.category.Add(product_category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product_category));
        }
Пример #6
0
 public ActionResult Edit([Bind(Include = "id,product_id,category_id")] product_category product_category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product_category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.category_id = new SelectList(db.categories, "id", "name", product_category.category_id);
     ViewBag.product_id  = new SelectList(db.products, "id", "name", product_category.product_id);
     return(View(product_category));
 }
Пример #7
0
        // GET: product_category/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            product_category product_category = db.product_category.Find(id);

            if (product_category == null)
            {
                return(HttpNotFound());
            }
            return(View(product_category));
        }
Пример #8
0
 public bool DeleteProductCategory(long product_category_id)
 {
     try
     {
         product_category oProductCategory = _entities.product_category.FirstOrDefault(c => c.product_category_id == product_category_id);
         oProductCategory.is_active  = false;
         oProductCategory.is_deleted = true;
         _entities.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #9
0
        // GET: product_category/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            product_category product_category = db.product_category.Find(id);

            if (product_category == null)
            {
                return(HttpNotFound());
            }
            ViewBag.category_id = new SelectList(db.categories, "id", "name", product_category.category_id);
            ViewBag.product_id  = new SelectList(db.products, "id", "name", product_category.product_id);
            return(View(product_category));
        }
Пример #10
0
        public bool EditProductCategory(product_category product_category)
        {
            try
            {
                product_category oProductCategory = _entities.product_category.Find(product_category.product_category_id);
                oProductCategory.product_category_name = product_category.product_category_name;
                oProductCategory.product_category_code = product_category.product_category_code;
                //updated_by =
                oProductCategory.updated_date = DateTime.Now;
                _entities.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #11
0
        public HttpResponseMessage Post([FromBody] Models.product_category product_category)
        {
            try
            {
                if (string.IsNullOrEmpty(product_category.product_category_name))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Name is Empty"
                    }, formatter));
                }
                else
                {
                    product_category insert_product_category = new product_category
                    {
                        product_category_name = product_category.product_category_name,
                        product_category_code = product_category.product_category_code
                    };



                    productCategoryRepository.AddProductCategory(insert_product_category);


                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "success", msg = "Product Category save successfully"
                    }, formatter));
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }