public IHttpActionResult Post(Tbl_Category category)
        {
            //adminLoginRepository.Insert(Admin);
            categoryrepository.Insert(category);

            return(Created("api/categorys/" + category.CategoryId, category));
        }
Пример #2
0
        public ActionResult UpdateCategory(CategoryDetail cd)
        {
            if (ModelState.IsValid)
            {
                Tbl_Category cat = _unitOfWork.GetRepositoryInstance <Tbl_Category>().GetFirstOrDefault(cd.CategoryId);
                cat = cat != null ? cat : new Tbl_Category();
                cat.CategoryName = cd.CategoryName;
                if (cd.CategoryId != 0)
                {
                    _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(cat);
                    _unitOfWork.SaveChanges();
                }
                else
                {
                    cat.IsActive = true;
                    cat.IsDelete = false;
                    _unitOfWork.GetRepositoryInstance <Tbl_Category>().Add(cat);
                }

                return(RedirectToAction("Categories"));
            }
            else
            {
                return(View("UpdateCategory", cd));
            }
        }
Пример #3
0
 public ActionResult AddCategory(Tbl_Category new_c)
 {
     _unitOfWork.GetRepositoryInstance <Tbl_Category>().Add(new_c);
     //dbMyOnlineShoppingEntities db = new dbMyOnlineShoppingEntities();
     //db.func_insert_category(new_c.CategoryName, new_c.IsActive, new_c.IsDelete);
     return(RedirectToAction("Categories"));
 }
Пример #4
0
        public ActionResult Delete(int?id, Tbl_Category category)
        {
            Tbl_Category cate = new Tbl_Category();

            try
            {
                if (ModelState.IsValid)
                {
                    if (id == null)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }
                    cate = db.Tbl_Category.Find(id);
                    if (cate == null)
                    {
                        return(HttpNotFound());
                    }
                    db.Tbl_Category.Remove(cate);
                    db.SaveChanges();
                }
                //return View(cate);
                return(RedirectToAction("Index"));
                // TODO: Add delete logic here
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult UpdateCategory(Tbl_Category category)
        {
            if (Session["AdminId"] != null)
            {
                category.IsActive = true;
                category.IsDelete = false;

                var name = _DBEntity.Tbl_Category.Where(a => a.CategoryName == category.CategoryName).ToList();

                if (name.Count() >= 1)
                {
                    ViewBag.Message = " sorry , this Category is allready taken";
                    return(View());
                }
                else
                {
                    _DBEntity.Tbl_Category.Add(category);
                    _DBEntity.SaveChanges();
                    return(RedirectToAction("Categories"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }


            //_unitOfWork.GetRepositoryInstance<Tbl_Category>().Add(category);
        }
Пример #6
0
 public ActionResult CategoryEdit(Tbl_Category table)
 {
     using (GenericUnitOfWork _unitOfWork = new GenericUnitOfWork())
     {
         _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(table);
         return(RedirectToAction("Categories"));
     }
 }
Пример #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tbl_Category tbl_Category = db.Tbl_Category.Find(id);

            db.Tbl_Category.Remove(tbl_Category);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
        public ActionResult CategoryDelete(int categoryId)
        {
            Tbl_Category det = unit.GetRepositoryInstance <Tbl_Category>().GetFirstorDefault(categoryId);

            det.IsDelete = true;
            unit.GetRepositoryInstance <Tbl_Category>().Update(det);
            return(RedirectToAction("Categories"));
        }
        // [ValidateAntiForgeryToken]
        // [Authorize(Roles = "Admin")]
        public ActionResult DeleteConfirmed(int id)
        {
            Tbl_Category employee = db.Tbl_Category.Find(id);

            db.Tbl_Category.Remove(employee);
            db.SaveChanges();
            return(RedirectToAction("Categories_List"));
        }
Пример #10
0
        public void Tbl_Category_CompareTwoAsserts_AreEqual()
        {
            var actual = new Tbl_Category {
                Cat_ID = 1, Cat_Name = "C#"
            };

            Assert.AreEqual(1, actual.Cat_ID);
            Assert.AreEqual("C#", actual.Cat_Name);
        }
Пример #11
0
 public ActionResult CategoryAdd(Tbl_Category tbl, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         _unitOfWork.GetRepositoryInstance <Tbl_Category>().Add(tbl);
         return(RedirectToAction("Categories"));
     }
     return(View(tbl));
 }
Пример #12
0
 public ActionResult Edit([Bind(Include = "Ca_ID,Ca_Name")] Tbl_Category tbl_Category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_Category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_Category));
 }
 public ActionResult UpdateCategory([Bind(Include = "CategoryId,CategoryName,IsActive,IsDelete")] Tbl_Category _cat)
 {
     if (ModelState.IsValid)
     {
         db.Entry(_cat).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Categories_List"));
     }
     return(View(_cat));
 }
 public ActionResult AddCategory([Bind(Include = "CategoryId,CategoryName,IsActive,IsDelete")] Tbl_Category _cat)
 {
     if (ModelState.IsValid)
     {
         db.Tbl_Category.Add(_cat);
         db.SaveChanges();
         return(RedirectToAction("Categories_List"));
     }
     return(View(_cat));
 }
Пример #15
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tbl_Category tbl_Category = db.Categories.Find(id);

            tbl_Category.IsActive       = false;
            tbl_Category.IsDelete       = true;
            tbl_Category.SalesmanUserId = User.Identity.GetUserId();
            db.Categories.AddOrUpdate(tbl_Category);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #16
0
        public void AddCategories(CategoryDetail category)
        {
            using (dbMyOnlineShoppingEntities db = new dbMyOnlineShoppingEntities())
            {
                Tbl_Category CA = new Tbl_Category();
                CA.CategoryName = category.CategoryName;

                db.Tbl_Category.Add(CA);
                db.SaveChanges();
            }
        }
Пример #17
0
        public ActionResult Create([Bind(Include = "Ca_ID,Ca_Name")] Tbl_Category tbl_Category)
        {
            if (ModelState.IsValid)
            {
                db.Tbl_Category.Add(tbl_Category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_Category));
        }
Пример #18
0
 private static string GetEnumValue(Tbl_Category category)
 {
     try
     {
         return(Enum.Parse(typeof(Types), category.Type.ToString()).ToString());
     }
     catch (Exception)
     {
         return(string.Empty);
     }
 }
 public ActionResult CategoryEdit(Tbl_Category category)
 {
     if (Session["AdminId"] != null)
     {
         _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(category);
         return(RedirectToAction("Categories"));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
Пример #20
0
 public IActionResult CreateCategory(CategoryDetail model)
 {
     if (ModelState.IsValid)
     {
         Tbl_Category category = new Tbl_Category();
         category.CategoryName = model.CategoryName;
         category.IsActive     = model.IsActive;
         category.IsDelete     = model.IsDelete;
         cat_repository.Insert(category);
         return(RedirectToAction("AllCategories"));
     }
     return(View(model));
 }
Пример #21
0
 public ActionResult Edit([Bind(Include = "CategoryId,CategoryName,IsActive,IsDelete")] Tbl_Category tbl_Category)
 {
     if (ModelState.IsValid)
     {
         tbl_Category.IsActive        = true;
         tbl_Category.IsDelete        = false;
         tbl_Category.SalesmanUserId  = User.Identity.GetUserId();
         db.Entry(tbl_Category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_Category));
 }
Пример #22
0
        public ActionResult UpdateCategory([Bind(Include = "CategoryId,CategoryName")] Tbl_Category c)
        {
            Tbl_Category c_new = new Tbl_Category();

            c_new = _unitOfWork.GetRepositoryInstance <Tbl_Category>().GetFirstorDefault(c.CategoryId);
            c_new.CategoryName = c.CategoryName;


            _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(c_new);


            return(RedirectToAction("Categories"));
        }
Пример #23
0
 public static Category MapFrom(this Tbl_Category category)
 {
     return(new Category
     {
         Id = category.Id,
         Name = category.Name,
         Color = category.Color,
         Type = category.Type,
         TypeName = GetEnumValue(category),
         Enabled = category.Enabled,
         Created_At = category.Created_At,
         Updated_At = category.Updated_At,
     });
 }
Пример #24
0
        // GET: Category/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Category tbl_Category = db.Tbl_Category.Find(id);

            if (tbl_Category == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_Category));
        }
Пример #25
0
        // GET: Category/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Category cat = db.Tbl_Category.Find(id);

            if (cat == null)
            {
                return(HttpNotFound());
            }
            return(View(cat));
        }
Пример #26
0
        public ActionResult AddCategory(Tbl_Category catID)
        {
            //Tbl_Category cat;

            unit.GetRepositoryInstance <Tbl_Category>().Add(catID);

            //if (catID != null)
            //{
            //    cat = JsonConvert.DeserializeObject<CategoryDetails>(JsonConvert.SerializeObject(unit.GetRepositoryInstance<Tbl_Category>().GetFirstorDefault(catID)));
            //}
            //else
            //    cat = new Tbl_Category();

            return(RedirectToAction("Categories"));
        }
Пример #27
0
        // GET: Category/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Category cat = db.Tbl_Category.Find(id);

            db.Tbl_Category.Remove(cat);
            db.SaveChanges();
            if (cat == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Index"));
        }
Пример #28
0
        public ActionResult UpdateCategory(int categoryId)
        {
            //CategoryDetail cd;
            //if (categoryId != null)
            //{
            //    string json = JsonConvert.SerializeObject(_unitOfWork.GetRepositoryInstance<Tbl_Category>().GetFirstorDefault(categoryId));
            //    cd = JsonConvert.DeserializeObject<CategoryDetail>(json);

            //}
            //else
            //{
            //    cd = new CategoryDetail();
            //}
            Tbl_Category cd = _unitOfWork.GetRepositoryInstance <Tbl_Category>().GetFirstorDefault(categoryId);

            return(View(cd));
        }
Пример #29
0
        public ActionResult AddCategory(Tbl_Category cat)
        {
            List <Tbl_Category> li = db.Tbl_Category.OrderByDescending(x => x.Cat_ID).ToList();

            ViewData["List"] = li;

            Random r = new Random();

            Tbl_Category c = new Tbl_Category();

            c.Cat_Name      = cat.Cat_Name;
            c.cat_encrypted = crypto.Encrypt(cat.Cat_Name.Trim() + r.Next().ToString(), true);
            c.Cat_FK_adid   = Convert.ToInt32(Session["Ad_ID"].ToString());
            db.Tbl_Category.Add(c);
            db.SaveChanges();

            return(RedirectToAction("AddCategory"));
        }
Пример #30
0
 public ActionResult Create(Tbl_Category category)
 {
     try
     {
         if (ModelState.IsValid)
         {
             category.CreatedDate = DateTime.Now;
             db.Tbl_Category.Add(category);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         // TODO: Add insert logic here
         return(View(category));
     }
     catch
     {
         return(View());
     }
 }