Example #1
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            BookLetViewModel book = new BookLetViewModel();

            book = bookLetServices.GetBookLetById(id);
            if (book == null)
            {
                return(NotFound());
            }
            List <SelectListItem> activity = new List <SelectListItem>();

            activity.Add(new SelectListItem {
                Text = "Commerical", Value = "0"
            });
            activity.Add(new SelectListItem {
                Text = "Agriculture", Value = "1"
            });
            activity.Add(new SelectListItem {
                Text = "Other", Value = "2"
            });
            ViewBag.activity = new SelectList(activity, "Value", "Text", book.Activity);

            return(View(book));
        }
Example #2
0
        public void UpdateBookLet(BookLetViewModel model)
        {
            BookLetTable book = db.BookLet.Find(model.Id);

            db.Entry(book).State = EntityState.Modified;
            book.Activity        = model.Activity;
            db.SaveChanges();
        }
Example #3
0
        public void AddBookLet(BookLetViewModel model)
        {
            BookLetTable book = new BookLetTable {
                Activity = model.Activity, Status = 0
            };

            db.BookLet.Add(book);
            db.SaveChanges();
        }
Example #4
0
        public BookLetViewModel GetBookLetById(int?Id)
        {
            BookLetViewModel book = db.BookLet.Where(x => x.Id == Id.Value).Select(x => new BookLetViewModel
            {
                Id       = x.Id,
                Activity = x.Activity,
                Status   = x.Status
            }).FirstOrDefault();

            return(book);
        }
Example #5
0
 public ActionResult Edit(int id, BookLetViewModel model)
 {
     try
     {
         bookLetServices.UpdateBookLet(model);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Example #6
0
        public ActionResult Create(BookLetViewModel model)
        {
            try
            {
                bookLetServices.AddBookLet(model);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
Example #7
0
        public ActionResult Create()
        {
            List <SelectListItem> activity = new List <SelectListItem>();

            activity.Add(new SelectListItem {
                Text = "Commerical", Value = "0"
            });
            activity.Add(new SelectListItem {
                Text = "Agriculture", Value = "1"
            });
            activity.Add(new SelectListItem {
                Text = "Other", Value = "2"
            });
            ViewBag.activity = activity;
            BookLetViewModel book = new BookLetViewModel();

            return(View(book));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            BookLetSalesViewModel bookLetSale = new BookLetSalesViewModel();

            bookLetSale = bookLetSaleServices.GetBookLetSaleById(id);
            if (bookLetSale == null)
            {
                return(NotFound());
            }
            List <BookLetViewModel> allBookAvailableIncludeCurrent = bookLetSaleServices.GetAllBookLetAvaliable();
            BookLetViewModel        book = bookLetServices.GetBookLetById(bookLetSale.BookLetId);

            allBookAvailableIncludeCurrent.Add(book);
            ViewBag.bookList = new SelectList(allBookAvailableIncludeCurrent.OrderBy(x => x.Id), "Id", "Id", book);
            return(View(bookLetSale));
        }