public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Discription")] Categoty categoty)
        {
            if (id != categoty.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategotyExists(categoty.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoty));
        }
        public ActionResult Save(FormCollection form)
        {
            string       fileName        = "";
            ResultObject result_object   = new ResultObject();
            Categoty     category_object = new Categoty();

            foreach (string file in Request.Files)
            {
                var fileContent = Request.Files[file];
                if (fileContent != null && fileContent.ContentLength > 0)
                {
                    // get a stream
                    var stream = fileContent.InputStream;
                    // and optionally write the file to disk

                    var extension = Path.GetExtension(file);
                    fileName = Guid.NewGuid().ToString() + extension;//Path.GetFileName(file);
                    var path = Path.Combine(Server.MapPath("~/images"), fileName);
                    using (var fileStream = System.IO.File.Create(path))
                    {
                        stream.CopyTo(fileStream);
                    }
                }
            }
            category_object.Save(form, fileName, result_object);
            return(Json(result_object, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Search(int?category_id, string searchText, int status)
        {
            ResultObject result_object   = new ResultObject();
            Categoty     category_object = new Categoty();

            category_object.Search(category_id, searchText, status, result_object);
            return(Json(result_object, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Categoty categoty = db.categoties.Find(id);

            db.categoties.Remove(categoty);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult CategoryManagement()
        {
            ResultObject result_object   = new ResultObject();
            Categoty     Categoty_object = new Categoty();

            Categoty_object.GetList(null, "", 1, result_object);
            return(View(Categoty_object));
        }
        public IActionResult News(int id)
        {
            Categoty ctu = db.categoties.Find(id);

            ViewBag.name = ctu.Name;
            var news = db.news.Where(x => x.categoeyId == id).OrderByDescending(x => x.Date).ToList();

            return(View(news));
        }
Пример #7
0
 public ActionResult Edit([Bind(Include = "CategoryID,CategoryName,Description")] Categoty categoty)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoty).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoty));
 }
Пример #8
0
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName,Description")] Categoty categoty)
        {
            if (ModelState.IsValid)
            {
                db.categoties.Add(categoty);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categoty));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Discription")] Categoty categoty)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categoty);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoty));
        }
Пример #10
0
        // GET: Categoties/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Categoty categoty = db.categoties.Find(id);

            if (categoty == null)
            {
                return(HttpNotFound());
            }
            return(View(categoty));
        }
Пример #11
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Categoty = await _context.categories.FirstOrDefaultAsync(m => m.Id == id);

            if (Categoty == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #12
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Categoty = await _context.categories.FindAsync(id);

            if (Categoty != null)
            {
                _context.categories.Remove(Categoty);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }