public async Task <int> ThemKhachSan(CauHinhKhachSanRequiter khachsan) { KhachSan khachsanadd = new KhachSan(); //khachsanadd.ID_KhachSan = khachsan.ID_KhachSan; khachsanadd.TenKhachSan = khachsan.TenKhachSan; khachsanadd.CreateBy = khachsan.CreateBy; khachsanadd.LogoKhachSan = khachsan.LogoKhachSan; khachsanadd.CreateDate = DateTime.Now; khachsanadd.Delete = khachsan.Delete; khachsanadd.DiaChiKhachSan = khachsan.DiaChiKhachSan; khachsanadd.Email = khachsan.Email; khachsanadd.Facebook = khachsan.Facebook; khachsanadd.Hotline = khachsan.Hotline; khachsanadd.LastModifiedDate = DateTime.Now; khachsanadd.MaKhachSan = khachsan.MaKhachSan; khachsanadd.ModifyBy = khachsan.ModifyBy; khachsanadd.SoDiDong = khachsan.SoDiDong; khachsanadd.SoFax = khachsan.SoFax; khachsanadd.SoMayBan = khachsan.SoMayBan; khachsanadd.TrangThai = khachsan.TrangThai; khachsanadd.Twitter = khachsan.Twitter; khachsanadd.Website = khachsan.Website; khachsanadd.Youtube = khachsan.Youtube; khachsanadd.Instagram = khachsan.Instagram; khachsanadd.GioiThieu = khachsan.GioiThieu; khachsanadd.ViTri = khachsan.ViTri; _context.KhachSans.Add(khachsanadd); await _context.SaveChangesAsync(); return(khachsanadd.ID_KhachSan); }
public async Task <IActionResult> ThemKhachSan([FromForm] CauHinhKhachSanRequiter khachsan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var test = await _khachSanService.ThemKhachSan(khachsan); return(Ok(test)); }
public async Task <int> SuaKhachSan(CauHinhKhachSanRequiter khachsan) { KhachSan detailKhachSan = _context.KhachSans.Where(a => a.ID_KhachSan == khachsan.ID_KhachSan).FirstOrDefault(); if (detailKhachSan == null) { throw new Exception("Công ty không tồn tại."); } //detailKhachSan.ID_KhachSan = khachsan.ID_KhachSan; detailKhachSan.TenKhachSan = khachsan.TenKhachSan; detailKhachSan.LogoKhachSan = khachsan.LogoKhachSan; detailKhachSan.CreateBy = khachsan.CreateBy; detailKhachSan.CreateDate = DateTime.Now; detailKhachSan.Delete = khachsan.Delete; detailKhachSan.DiaChiKhachSan = khachsan.DiaChiKhachSan; detailKhachSan.Email = khachsan.Email; detailKhachSan.Facebook = khachsan.Facebook; detailKhachSan.Hotline = khachsan.Hotline; detailKhachSan.LastModifiedDate = DateTime.Now; detailKhachSan.MaKhachSan = khachsan.MaKhachSan; detailKhachSan.ModifyBy = khachsan.ModifyBy; detailKhachSan.SoDiDong = khachsan.SoDiDong; detailKhachSan.SoFax = khachsan.SoFax; detailKhachSan.SoMayBan = khachsan.SoMayBan; detailKhachSan.TrangThai = khachsan.TrangThai; detailKhachSan.Twitter = khachsan.Twitter; detailKhachSan.Website = khachsan.Website; detailKhachSan.Youtube = khachsan.Youtube; detailKhachSan.Instagram = khachsan.Instagram; detailKhachSan.GioiThieu = khachsan.GioiThieu; detailKhachSan.ViTri = khachsan.ViTri; _context.KhachSans.Update(detailKhachSan); await _context.SaveChangesAsync(); return(detailKhachSan.ID_KhachSan); }
public async Task <IActionResult> SuaKhachSan([FromForm] CauHinhKhachSanRequiter khachsan) { var test = await _khachSanService.SuaKhachSan(khachsan); return(Ok(test)); }