Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(BenhNhanEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var dbItem = await _context.NoiDungTinhChiTiet.FirstOrDefaultAsync(h => h.Id == model.Id);

            if (dbItem == null)
            {
                return(NotFound());
            }

            dbItem.TieuDe    = model.TieuDe;
            dbItem.GioiThieu = model.GioiThieu;
            dbItem.NoiDung   = model.NoiDung;
            dbItem.HinhAnh   = model.HinhAnh;

            dbItem.NgayChinhSua   = DateTime.Now;
            dbItem.FkUserChinhsua = "admin";

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Edit), new { id = model.Id }));
        }
        public async Task <IActionResult> Edit(GioiThieuKhoaBanEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var dbItem = await _context.KhoaPhong.FirstOrDefaultAsync(h => h.Id == model.Id);

            if (dbItem == null)
            {
                return(NotFound());
            }

            dbItem.TieuDeKhoa     = model.TieuDe;
            dbItem.GioiThieu      = model.GioiThieu;
            dbItem.NoiDung        = model.NoiDung;
            dbItem.HinhAnhDaiDien = model.HinhAnh;

            dbItem.NgayCapNhat = DateTime.Now;
            dbItem.UserModify  = "admin";

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Edit), new { id = model.Id }));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Gio")] GioKham gioKham)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gioKham);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gioKham));
        }
        public async Task <IActionResult> Create([Bind("Id,HoVaTen,DienThoaiNha,DienThoaiDiDong,Email,NoiDung,NgayGui,DaXem,FkNguoiXem,NgayXem,TieuDe")] LienHeKhachHang lienHeKhachHang)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lienHeKhachHang);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkNguoiXem"] = new SelectList(_context.User, "UserName", "UserName", lienHeKhachHang.FkNguoiXem);
            return(View(lienHeKhachHang));
        }
        public async Task <IActionResult> Create([Bind("Id,NgayKham,MaSoBenhNhan,HoVaTen,Email,NgaySinh,GioiTinh,DienThoai,NoiDung,NgayGui,DaXem,FkLoaiPhanHoi,FkNgonNgu,NoiDungTraLoi,NgayTraLoi,FkUserTraLoi,DiaChi,IsShow,TieuDe")] PhanHoi phanHoi)
        {
            if (ModelState.IsValid)
            {
                var listNgonNgu = await GetListNgonNguAsync();

                ViewBag.ListNgonNgu = listNgonNgu;
                _context.Add(phanHoi);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkNgonNgu"]    = new SelectList(_context.NgonNgu, "Id", "Id", phanHoi.FkNgonNgu);
            ViewData["FkUserTraLoi"] = new SelectList(_context.User, "UserName", "UserName", phanHoi.FkUserTraLoi);
            return(View(phanHoi));
        }
        public async Task <IActionResult> Create([Bind("Id,TieuDe,NoiDungCauHoi,HoTenNguoiHoi,GioiTinh,FkNamSinh,NoiDungTraLoi,NgayGuiCauHoi,NgayTraLoi,NguoiTraLoi,IsShow,FkChuyenKhoa,FkUserTraLoi,DaTraLoi,Email,DiaChi,SoDienThoai")] HoiDapYkhoa hoiDapYkhoa)
        {
            if (ModelState.IsValid)
            {
                var listNamSinh = await GetListNamSinhAsync();

                ViewBag.ListNamSinh = listNamSinh;
                var listChuyenKhoa = await GetListChuyenKhoaAsync();

                ViewBag.ListChuyenKhoa = listChuyenKhoa;

                _context.Add(hoiDapYkhoa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkChuyenKhoa"] = new SelectList(_context.LoaiCauHoi, "Id", "Id", hoiDapYkhoa.FkChuyenKhoa);
            ViewData["FkNamSinh"]    = new SelectList(_context.NamSinh, "Id", "Id", hoiDapYkhoa.FkNamSinh);
            ViewData["FkUserTraLoi"] = new SelectList(_context.User, "UserName", "UserName", hoiDapYkhoa.FkUserTraLoi);
            return(View(hoiDapYkhoa));
        }