void RefreshCustomer(Cust2 newCust, Cust2 oldCust) { if (!oldCust.Email.Equals(newCust.Email)) { oldCust.Email = newCust.Email; } if (!oldCust.Fname.Equals(newCust.Fname)) { oldCust.Fname = newCust.Fname; } }
public bool SaveOrder(CallCenter model) { bool result = false; //create address Address address = new Address() { Address_City = model.Address_City, Address_ZIPCODE = model.Address_ZIPCODE, Address_Numder_Appartment = model.Address_Numder_Appartment, Address_Country = model.Address_Country, Address_line1 = model.Address_line1, Address_line2 = model.Address_line2, Address_Name_Street = model.Address_Name_Street, Address_Number_Street = model.Address_Number_Street, Address_State = model.Address_State, }; db.Addresses.Add(address); //create customer Cust2 cust2 = new Cust2() { Lname = model.Client.Lname, Fname = model.Client.Fname, Address = address, Email = model.Client.Email, Phone = model.Client.Phone, Gender = model.Gender }; db.Cust2.Add(cust2); //create order int id = 0; int.TryParse(model.ComboBouqets, out id); int quantities = 0; int.TryParse(model.ComboQuantities, out quantities); decimal summ = 0; decimal.TryParse(model.Sum, out summ); Order_Del order = new Order_Del() { Bouquet_ID = id, Florist_ID = 25, Cust2 = cust2, Driver_ID = 1000, Order_Date = DateTime.Today, Bouquet_Quontity = quantities, Date_Delived = DateDelivery, Total_Price = summ, Size_Bouquets = model.ComboSizes, Order_Status = "Payed" }; db.Order_Del.Add(order); try { db.SaveChanges(); return(true); } catch (Exception ex) { return(result); } }
/// <summary> /// Редактирование старой заявки /// </summary> /// <param name="model"></param> /// <returns></returns> bool EditOldOrder(CallCenter model) { bool result = false; // var oldOrderFromDB = db.Order_Del.FirstOrDefault(d => d.Order_ID == model.Order_ID); var oldAddress = oldOrderFromDB.Cust2.Address; var oldCustomer = oldOrderFromDB.Cust2; Address address = new Address() { Address_City = model.Address_City, Address_ZIPCODE = model.Address_ZIPCODE, Address_Numder_Appartment = model.Address_Numder_Appartment, Address_Country = model.Address_Country, Address_line1 = model.Address_line1, Address_line2 = model.Address_line2, Address_Name_Street = model.Address_Name_Street, Address_Number_Street = model.Address_Number_Street, Address_State = model.Address_State, }; RefreshAddress(address, oldAddress); //create customer Cust2 cust2 = new Cust2() { Lname = model.Client.Lname, Fname = model.Client.Fname, Email = model.Client.Email, Phone = model.Client.Phone, Gender = model.Gender }; RefreshCustomer(cust2, oldCustomer); //create order int id = 0; int.TryParse(model.ComboBouqets, out id); int quantities = 0; int.TryParse(model.ComboQuantities, out quantities); decimal summ = 0; decimal.TryParse(model.Sum, out summ); Order_Del order = new Order_Del() { Bouquet_ID = id, Bouquet_Quontity = quantities, Date_Delived = DateDelivery, Total_Price = summ, Size_Bouquets = model.ComboSizes, }; RefresOrder(order, oldOrderFromDB); try { db.SaveChanges(); return(true); } catch (Exception ex) { return(result); } }