public void EditOrder() { var options = TestInit(); using (RMGContext db = new RMGContext(options)) { var order = db.Orders.Last <Order>(); order.Priece = "444444444444"; order.RealEstateId = 2; order.Type = OrderType.Purchase; order.UserId = 1; order.UserName = "******"; db.Orders.Update(order); db.SaveChanges(); var result = db.Orders.Last <Order>(); var expected = new Order(); expected.Priece = "444444444444"; expected.RealEstateId = 2; expected.Type = OrderType.Purchase; expected.UserId = 1; expected.UserName = "******"; OrderEquals(expected, result); } }
public void SetNewUser() { var options = TestInit(); using (RMGContext db = new RMGContext(options)) { var newUser = new User(); newUser.EMail = "*****@*****.**"; newUser.FIO = "Admin AAAA"; newUser.Orders = null; newUser.Password = "******"; newUser.Phone = "8(902) 345-66-89"; db.Users.Add(newUser); db.SaveChanges(); var result = db.Users.Last <User>(); var expected = new User(); expected.EMail = "*****@*****.**"; expected.FIO = "Admin AAAA"; expected.Orders = null; expected.Password = "******"; expected.Phone = "8(902) 345-66-89"; UserEquals(expected, result); } }
public void SetNewOrder() { var options = TestInit(); using (RMGContext db = new RMGContext(options)) { var newOrder = new Order(); newOrder.Priece = "1500"; newOrder.RealEstateId = 2; newOrder.Type = OrderType.Purchase; newOrder.UserId = 1; newOrder.UserName = "******"; db.Orders.Add(newOrder); db.SaveChanges(); var result = db.Orders.Last <Order>(); var expected = new Order(); expected.Priece = "1500"; expected.RealEstateId = 2; expected.Type = OrderType.Purchase; expected.UserId = 1; expected.UserName = "******"; OrderEquals(expected, result); } }
public IActionResult Profile(User User) { User u = Initialize().Result; if (u == null || User == null) { return(Redirect("~/Home/Sorry")); } u.EMail = User.EMail; u.Phone = User.Phone; u.FIO = User.FIO; db.Users.Update(u); db.SaveChanges(); return(Redirect("~/Home/Profile?id=0")); }
public static void Initialize(RMGContext context) { if (!context.Users.Any()) { User u = new User { EMail = "*****@*****.**", FIO = "Wesley Snipes", Password = "******", Phone = "88005553535", Orders = new List <Order> { } }; context.Users.Add(u); context.SaveChanges(); // Location l1 = new Location // { // City = "City", // Country = "Country", // ApartmentsNumber = "12", // HouseBlockNumber = "32s", // Street = "street", // HouseNumber = "34" // }; // Property p1 = new Property // { // AmountOfFloors = "2", // AmountOfRooms = "7", // Area = "45", // Height = "25" // }; // RealEstate e1 = new RealEstate // { // Name = "House", // Location = l1, // Property = p1, // Type = TypeEstate.Accommodation, // Description = "Easy description for real estate", // Photo = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 } //}; // context.RealEstates.Add(e1); // context.SaveChanges(); // Order o1 = new Order // { // UserId = u.Id, // RealEstateId = e1.Id, // Priece = "9999", // UserName = u.FIO, // //RealEstate = e1, // Type = OrderType.Sale // }; // context.Orders.Add(o1); // context.SaveChanges(); // //------------------------------------------------------------------------------------------ // Location l2 = new Location // { // City = "City1", // Country = "Country1", // Street = "street1", // HouseNumber = "85", // ApartmentsNumber="", // HouseBlockNumber = "" // }; // Property p2 = new Property // { // AmountOfFloors = "12", // AmountOfRooms = "17", // Area = "145", // Height = "" // }; // RealEstate e2 = new RealEstate // { // Name = "The Mordor Earth", // Location = l2, // Property = p2, // Type = TypeEstate.LandPlot, // Description = "F*****g description for this real estates", // Photo = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 } //}; // context.RealEstates.Add(e2); // context.SaveChanges(); // Order o2 = new Order // { // UserId = u.Id, // RealEstateId = e2.Id, // //RealEstate = e2, // Priece = "20000000", // UserName = u.FIO, // Type = OrderType.Sale // }; // context.Orders.Add(o2); // context.SaveChanges(); } }