public virtual int Create(Author entity) { try { object insertedItem = Context.Authors.Add(entity); Context.SaveChanges(); return(insertedItem != null?int.TryParse(insertedItem.ToString(), out int result) ? result : 0 : 0); } catch (Exception ex) { throw; } }
public void DatPhong(DatPhong dp) { DatPhong _d = new DatPhong(); //KhachHang _k = new KhachHang(); _d.NgayNhan = dp.NgayNhan; _d.NgayTra = dp.NgayTra; _d.NgayDat = dp.NgayDat; _d.MaKH = dp.MaKH; _d.SoPhong = dp.SoPhong; _d.MaPhong = dp.MaPhong; _d.SoNguoiLon = dp.SoNguoiLon; _d.SoTreEm = dp.SoTreEm; Model m = new Model(); m.DatPhong.Add(_d); m.SaveChanges(); }