예제 #1
0
        public IActionResult Create(DieuHanh dieuHanh)
        {
            dieuHanh.NgayKhoiHanh = dieuHanh.NgayKhoiHanh.Date;
            dieuHanh.CreatedTime  = DateTime.Now;
            dieuHanh.Status       = 0;
            _context.Add(dieuHanh);

            var soluongghe = _context.Xes.Find(dieuHanh.MaXe).SoLuongGhe;

            var listGhe = new List <ChoNgoi>();

            for (var i = 1; i <= soluongghe; i++)
            {
                listGhe.Add(new ChoNgoi
                {
                    DieuHanh     = dieuHanh,
                    TinhTrang    = 0,
                    ViTriChoNgoi = i
                });
            }

            _context.ChoNgois.AddRange(listGhe);

            _context.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }
예제 #2
0
 public IActionResult Create(TuyenXe tuyenXe)
 {
     tuyenXe.CreatedTime = DateTime.Now;
     tuyenXe.IsDelete    = 0;
     _context.Add(tuyenXe);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public IActionResult Create(Admins admin)
 {
     if (_context.Admins.Where(e => e.UserName == admin.UserName).Count() > 0)
     {
         return(NotFound());
     }
     admin.MatKhau      = GetMD5(admin.MatKhau);
     admin.IsSuperAdmin = 0;
     _context.Add(admin);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public async Task <IActionResult> Create([Bind("UserID,SDT,MatKhau,Email,HoTen,GioiTinh,DiaChi,NgaySinh,Avatar,CreatedTime,UpdateTime")] NguoiDung nguoiDung)
        {
            if (ModelState.IsValid)
            {
                nguoiDung.MatKhau     = nguoiDungLogic.GetMD5(nguoiDung.MatKhau);
                nguoiDung.CreatedTime = DateTime.Now;
                _context.Add(nguoiDung);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nguoiDung));
        }
        public bool Register(string sdt, string email, string matkhau)
        {
            var createTime = DateTime.Now;

            try
            {
                var nguoiDung = new NguoiDung
                {
                    SDT         = sdt,
                    Email       = email,
                    MatKhau     = GetMD5(matkhau),
                    CreatedTime = createTime
                };
                context.Add(nguoiDung);
                context.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
 public IActionResult Create(Xe xe)
 {
     _context.Add(xe);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }