Пример #1
0
        public async Task <int> Xoa(int id)
        {
            SoNguoiToiDa songuoitoida = _context.SoNguoiToiDas.Where(a => a.ID_SoNguoiToiDa == id).FirstOrDefault();

            if (songuoitoida == null)
            {
                throw new Exception("Ngôn ngức khách sạn không tồn tại.");
            }
            songuoitoida.Delete = true;
            _context.SoNguoiToiDas.Update(songuoitoida);
            await _context.SaveChangesAsync();

            return(songuoitoida.ID_SoNguoiToiDa);
        }
Пример #2
0
        public async Task <int> Them(SoNguoiToiDaRequest model)
        {
            SoNguoiToiDa songuoitoida = new SoNguoiToiDa();

            songuoitoida.ModifyBy        = model.ModifyBy;
            songuoitoida.CreateBy        = model.CreateBy;
            songuoitoida.Delete          = model.Delete;
            songuoitoida.ID_NgonNgu      = model.ID_NgonNgu;
            songuoitoida.ID_SoNguoiToiDa = model.ID_SoNguoiToiDa;
            songuoitoida.NoiDungHienThi  = model.NoiDungHienThi;
            songuoitoida.CreateDate      = DateTime.Now;
            _context.SoNguoiToiDas.Add(songuoitoida);
            await _context.SaveChangesAsync();

            return(songuoitoida.ID_SoNguoiToiDa);
        }
Пример #3
0
        public async Task <int> Sua(SoNguoiToiDaRequest model)
        {
            SoNguoiToiDa songuoitoida = _context.SoNguoiToiDas.Where(a => a.ID_SoNguoiToiDa == model.ID_SoNguoiToiDa).FirstOrDefault();

            if (songuoitoida == null)
            {
                throw new Exception("Ngôn ngữ khách sạn không tồn tại.");
            }
            songuoitoida.ModifyBy         = model.ModifyBy;
            songuoitoida.CreateBy         = model.CreateBy;
            songuoitoida.Delete           = model.Delete;
            songuoitoida.ID_NgonNgu       = model.ID_NgonNgu;
            songuoitoida.ID_SoNguoiToiDa  = model.ID_SoNguoiToiDa;
            songuoitoida.NoiDungHienThi   = model.NoiDungHienThi;
            songuoitoida.LastModifiedDate = DateTime.Now;
            _context.SoNguoiToiDas.Update(songuoitoida);
            await _context.SaveChangesAsync();

            return(songuoitoida.ID_SoNguoiToiDa);
        }