public IActionResult Post([FromBody] Division division) { if (division == null) { return(BadRequest()); } division.DateTime = DateTime.Now; db.Add(division); db.SaveChanges(); return(Ok(division)); }
public ActionResult Create([Bind(Include = "FeatureID,Name")] Feature feature) { if (ModelState.IsValid) { db.Features.Add(feature); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(feature)); }
public IActionResult Post([FromBody] Realtor realtor) { if (realtor == null) { return(BadRequest()); } realtor.DateTime = DateTime.Now; db.Add(realtor); db.SaveChanges(); return(Ok(realtor)); }
//изменение данных о картинке internal void ChangePicture(int indexApart, byte[] bt) { using (RealtorContext db = new RealtorContext()) { Picture pc = db.Pictures.Where(p => p.ApartmentId == indexApart).FirstOrDefault(); pc.ApartmentId = indexApart; pc.Image = bt; db.SaveChanges(); } }
//измен данных о работнике internal void ChangeEmployee(string FName, string LName, string Password, string Email, string Position, int index) { using (RealtorContext db = new RealtorContext()) { Employee e = db.Employees.Where(em => em.Id == index).FirstOrDefault(); e.FirstName = FName; e.SecondName = LName; e.Email = Email; e.Password = Password; e.Position = Position; db.SaveChanges(); } }
//добавление картинки public void AddPicture(int index, byte[] bt) { Picture pc = new Picture(); using (RealtorContext db = new RealtorContext()) { pc.ApartmentId = index; pc.Image = bt; db.Pictures.Add(pc); db.SaveChanges(); } }
private void updateRealtorButton_Click(object sender, RoutedEventArgs e) { if (realtorGrid.Items.Count > 0) { for (int i = 0; i < realtorGrid.Items.Count; i++) { Realtor relator = realtorGrid.Items[i] as Realtor; if (relator != null) { string error = canInsertNewRealtor(relator); if (error != null) { MessageBox.Show("Строка: " + i + " " + error); return; } else { realtorContext.SaveChanges(); } } } } }
//добав нового работника public void AddEmployee(string FName, string LName, string Email, string Password, string Position) { Employee em = new Employee(); using (RealtorContext db = new RealtorContext()) { em.FirstName = FName; em.SecondName = LName; em.Email = Email; em.Password = Password; em.Position = Position; db.Employees.Add(em); db.SaveChanges(); } }
public void SaleApart(int indexApart) { Purchase pr = new Purchase(); using (RealtorContext db = new RealtorContext()) { db.Clients.Add(new Client { FirstName = "2", SecondName = "1" }); pr.ApartmentId = indexApart; pr.ClientId = 1; pr.DatePurchase = DateTime.Now; db.Purchases.Add(pr); db.SaveChanges(); } }
public string DeleteHouse(HouseListing listing) { if (listing != null) { using (RealtorContext dataContext = new RealtorContext()) { int no = Convert.ToInt32(listing.Id); var houseList = dataContext.Houses.Where(x => x.Id == no).FirstOrDefault(); dataContext.Houses.Remove(houseList); dataContext.SaveChanges(); return("House Deleted"); } } else { return("Invalid House"); } }
public DivisionsController(RealtorContext context) { this.db = context; if (!db.Divisions.Any()) { db.Divisions.Add(new Division { Name = "First", DateTime = DateTime.Now }); db.Divisions.Add(new Division { Name = "Second", DateTime = DateTime.Now, }); db.SaveChanges(); } }
//изменение данных о квартире internal void ChangeApartment(string title, int area, int countRoom, int floor, int number, int price, string address, int index) { using (RealtorContext db = new RealtorContext()) { Apartment ap = db.Apartments.Where(a => a.Id == index).FirstOrDefault(); if (ap != null) { ap.Title = title; ap.Area = area; ap.CountRoom = countRoom; ap.Floor = floor; ap.Number = number; ap.Price = price; ap.Address = address; db.SaveChanges(); } } }
//Добав квартиры public int AddApartment(string title, int area, int countRoom, int floor, int number, int price, string address) { Apartment ap = new Apartment(); using (RealtorContext db = new RealtorContext()) { ap.Title = title; ap.Area = area; ap.CountRoom = countRoom; ap.Floor = floor; ap.Number = number; ap.Price = price; ap.Address = address; db.Apartments.Add(ap); db.SaveChanges(); return(db.Apartments.Where(ap2 => ap2.Title == title).Select(ap1 => ap1.Id).FirstOrDefault()); } }