Exemplo n.º 1
0
        // GET: Tourkind/Create
        public IActionResult Create()
        {
            Tourkind tourkind = new Tourkind();
            int      id       = _tourkindRepository.GetAll().OrderByDescending(x => x.Id).Take(1).SingleOrDefault().Id;

            tourkind.Id = id + 1;
            return(View(tourkind));
        }
Exemplo n.º 2
0
 public IActionResult Create([Bind("Id,TourkindInf")] Tourkind tourkind)
 {
     if (ModelState.IsValid)
     {
         tourkind.TourkindInf = tourkind.TourkindInf.ToUpper();
         var result = _tourkindRepository.Create(tourkind);
         if (result == null)
         {
             SetAlert("Thêm loại tour không thành công", "error");
         }
         else
         {
             SetAlert("Thêm loại tour thànhcông", "success");
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(tourkind));
 }
Exemplo n.º 3
0
        public IActionResult Edit(int id, [Bind("Id,TourkindInf")] Tourkind tourkind)
        {
            if (id != tourkind.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var result = _tourkindRepository.Update(tourkind);
                if (result == null)
                {
                    SetAlert("Cập nhật loại tour không thành công", "error");
                }
                else
                {
                    SetAlert("Cập nhật loại tour thành công", "success");
                }

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tourkind));
        }