public static Client AjouterClient(EcommerceDb db, Inscription inscription) { var client = TrouverClientParEmail(db, inscription.EmailAdresse); if (client == null) { client = DataManipulation.copyInscriptionToClient(inscription); db.Clients.Add(client); db.SaveChanges(); } else { client = null; //on reset le client a null afin de pouvoir envoyer le message d'errur car il existe deja dans la bd } return(client); //retour afin de determiner si on envoi message d'erreur,set cookie,etc }
public static List <ItemDetails> featuredInitialisation() { EcommerceDb db = new EcommerceDb();//on cherche 3 item var allItems = db.Items.ToList(); ItemDetails[] featuredItems = new ItemDetails[3]; int i = 0;//compteur while (true) { Random random = new Random(); int radomItem = random.Next(allItems.Count()); featuredItems[i] = DataManipulation.copyItemToItemDetails(allItems.ElementAt(radomItem)); i = ++i; if (i == 3) { break; } } return(featuredItems.ToList()); }