// ------------------------------- Utilitaires --------------------------- public static Contacts ContactMapping(ContactMapping contactMapping) { Contacts contacts = new Contacts(); contacts.Contact_Preferences = contactMapping.Contact_Preferences; contacts.Email_Address = contactMapping.Email_Address; contacts.Home_Phone = contactMapping.Home_Phone; contacts.Mobile_Phone = contactMapping.Mobile_Phone; return(contacts); }
public static Addresses AddressesMapping(ContactMapping contactMapping) { Addresses addresses = new Addresses(); addresses.AddressLine = contactMapping.AddressLine; addresses.City = contactMapping.City; addresses.Country = contactMapping.Country; addresses.Laltitude = contactMapping.Laltitude; addresses.Longitude = contactMapping.Longitude; addresses.PostalCode = contactMapping.PostalCode; return(addresses); }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.HasDefaultSchema("MainDb"); ApplicationUserMapping.Map(builder.Entity <ApplicationUser>()); ArticleArticleTagMapping.Map(builder.Entity <ArticleArticleTag>()); ArticleCommentMapping.Map(builder.Entity <ArticleComment>()); ArticleMapping.Map(builder.Entity <Article>()); ArticleRatingMapping.Map(builder.Entity <ArticleRating>()); ArticleTagMapping.Map(builder.Entity <ArticleTag>()); ContactMapping.Map(builder.Entity <Contact>()); PortfolioMapping.Map(builder.Entity <Portfolio>()); SiteOrderMapping.Map(builder.Entity <SiteOrder>()); SlideShowMapping.Map(builder.Entity <SlideShow>()); }
// Post client avec la police auto public ActionResult SaveAutoPolicy(ContactMapping contactMapping) { //Récuperer customer + auto via la variable session Customers customer = (Customers)Session["Customers"]; //Calculer le prix de la soumission double soumission_price = BusinessAuto.CalculAutoSoumission(customer.Autos); customer.Autos.Estimation_Per_Month = soumission_price; //Récuperer contact Contacts contacts = BusinessAuto.ContactMapping(contactMapping); //Récuperer adresse Addresses addresses = BusinessAuto.AddressesMapping(contactMapping); //Customer + auto + Adresse + Contact customer.Addresses = addresses; customer.Contacts = contacts; TempData["Price"] = soumission_price; using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44365/api/"); var responseTask = client.PostAsJsonAsync <Customers>("customers", customer); responseTask.Wait(); var results = responseTask.Result; if (results.IsSuccessStatusCode) { var readJob = results.Content.ReadAsAsync <Customers>(); readJob.Wait(); return(RedirectToAction("Confirme")); } else { ModelState.AddModelError(string.Empty, "An error is occured during the processing"); return(RedirectToAction("SaveAutoPolicy")); } } }