protected void AddBorrower_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.tbPermanentAddress.Text) || string.IsNullOrEmpty(this.tbPermanentAddress.Text) || string.IsNullOrEmpty(this.tbPermanentAddress.Text) || string.IsNullOrEmpty(this.tbMobileNumber.Text) || string.IsNullOrEmpty(this.tbLandlineNumber.Text) || string.IsNullOrEmpty(this.tbEmailAddress.Text)) { this.lblError.Visible = true; } else { Borrower _borrower = new Borrower() { Name = this.tbPermanentAddress.Text, HotelAddress = this.tbPermanentAddress.Text, PermanentAddress = this.tbPermanentAddress.Text, MobileNumber = this.tbMobileNumber.Text, LandLineNumber = this.tbLandlineNumber.Text, EmailAddress = this.tbEmailAddress.Text, CreatedOn = DateTime.Now, CreatedByID = 1 }; _ctx.Borrower.Add(_borrower); this.labelSaved.Visible = true; this.lblError.Visible = false; this.panelAddReservation.Visible = false; _ctx.SaveChanges(); } }
static void Main(string[] args) { CarRentalCtx _ctx = new CarRentalCtx(); User _myUser = new User { Username = "******" }; _ctx.User.Add(_myUser); _ctx.SaveChanges(); }