Example #1
0
        public static EnchereDAO EnchereToEnchereDAO(Enchere enchere)
        {
            string utilisateurid;
            string ordreachatid;

            if (enchere.OrdreAchatEnchere == null)
            {
                ordreachatid = null;
            }
            else
            {
                ordreachatid = enchere.OrdreAchatEnchere.IdOrdreAchat;
            }

            if (enchere.UtilisateurEnchere == null)
            {
                utilisateurid = null;
            }
            else
            {
                utilisateurid = enchere.UtilisateurEnchere.IdUtilisateur;
            }

            return(new EnchereDAO(enchere.IdEnchere, enchere.PrixProposer, enchere.IsAdjuger, enchere.DateHeureVente,
                                  enchere.LotEnchere.IdLot, enchere.CommissaireEnchere.IdCommissaire,
                                  ordreachatid, utilisateurid));
        }
Example #2
0
        private void btnReturn(object sender, RoutedEventArgs e)
        {
            Enchere ucObj = new Enchere();

            stkTest.Children.Clear();
            stkTest.Children.Add(ucObj);
        }
Example #3
0
 public AddEnchereView(Window win = null, Enchere user = null)
 {
     InitializeComponent();
     _win         = win;
     _utilisateur = null;
     _enchere     = user ?? new Enchere();
 }
Example #4
0
        public async Task <IActionResult> Miser(int id)
        {
            var objet = await _context.Objets
                        .Include(o => o.Encheres)
                        .ThenInclude(o => o.Miseur)
                        .Include(o => o.ConfigurationAdmin)
                        .Include(o => o.Acheteur)
                        .Include(o => o.Vendeur)
                        .SingleOrDefaultAsync(m => m.ObjetID == id);

            var encheres = objet.Encheres.ToList();

            bidMove = objet.ConfigurationAdmin.PasGlobalEnchere;
            Double[] enchereTableau = new Double[encheres.Count];

            var i = 0;

            foreach (Enchere item in encheres)
            {
                enchereTableau[i] = item.Niveau;
                i++;
            }

            var bestBid = Max(enchereTableau);

            Enchere newBid = new Enchere {
                Objet = objet, Niveau = bestBid, ObjetId = id
            };

            return(View(newBid));
        }
Example #5
0
 public EditEnchereView(Window win = null, Enchere enchere = null)
 {
     _enchere = enchere ?? new Enchere();
     InitializeComponent();
     GenerateControle();
     _win         = win;
     _utilisateur = _enchere.UtilisateurEnchere;
 }
Example #6
0
        public static Enchere GetEnchereById(string id, bool initializer = true)
        {
            var edao = EnchereDAL.SelectEnchereById(id);
            var commissaireEnchere = new Commissaire();
            var lotEnchere         = new Lot();
            var ordreAchatEnchere  = new OrdreAchat();
            var utilisateurEnchere = new Utilisateur();


            if (initializer)
            {
                commissaireEnchere =
                    CommissaireORM.GetCommissaireById(edao.CommissaireId, false);
                lotEnchere = LotORM.GetLotById(edao.LotId, false);
                if (edao.OrdreAchatId != null)
                {
                    ordreAchatEnchere =
                        OrdreAchatORM.GetOrdreAchatById(edao.OrdreAchatId, false);
                }

                if (edao.UtilisateurId != null)
                {
                    utilisateurEnchere =
                        UtilisateurORM.GetUtilisateurById(edao.UtilisateurId, false);
                }
            }

            var enchere = new Enchere(edao.IdEnchere, edao.PrixProposer, edao.EstAdjuger, edao.DateHeureVente,
                                      ordreAchatEnchere, lotEnchere, commissaireEnchere, utilisateurEnchere);

            if (initializer)
            {
                _encheresDictionary[enchere.IdEnchere] = enchere;

                CommissaireORM.Populate(new List <Commissaire>(new[]
                {
                    enchere.CommissaireEnchere
                }));
                LotORM.Populate(enchere.LotEnchere);
                if (edao.OrdreAchatId != null)
                {
                    OrdreAchatORM.Populate(enchere.OrdreAchatEnchere);
                }

                if (edao.UtilisateurId != null)
                {
                    UtilisateurORM.Populate(new List <Utilisateur>(new[]
                    {
                        enchere.UtilisateurEnchere
                    }));
                }
            }

            return(enchere);
        }
Example #7
0
        public static Produit GetProduitById(string id, bool initializer = true)
        {
            var pdao               = ProduitDAL.SelectProduitById(id);
            var lotProduit         = new Lot();
            var utilisateurProduit = new Utilisateur();
            var stockProduit       = new Stock();
            var enchereGagnante    = new Enchere();
            var categorieProduit   = new Categorie();


            if (initializer)
            {
                lotProduit         = LotORM.GetLotById(pdao.LotId, false);
                utilisateurProduit =
                    UtilisateurORM.GetUtilisateurById(pdao.UtilisateurId, false);
                stockProduit = StockORM.GetStockById(pdao.StockId, false);
                if (!string.IsNullOrEmpty(pdao.EnchereGagnanteId))
                {
                    enchereGagnante =
                        EnchereORM.GetEnchereById(pdao.EnchereGagnanteId, false);
                }

                //todo decomente ici
                // categorieProduit =
                //     CategorieORM.GetCategorieById(CategorieDAL.SelectCategorieById(pdao.CategorieId).CategorieId,
                //         false);
            }


            var produit = new Produit(pdao.IdProduit, lotProduit, utilisateurProduit, stockProduit, enchereGagnante,
                                      categorieProduit
                                      , pdao.NomArtiste, pdao.NomStyle, pdao.NomProduit, pdao.PrixReserve, pdao.ReferenceCatalogue,
                                      pdao.DescriptionProduit, pdao.IsSend);

            if (initializer)
            {
                _produitsDictionary[produit.IdProduit] = produit;

                LotORM.Populate(produit.LotProduit);
                UtilisateurORM.Populate(new List <Utilisateur>(new[]
                {
                    produit.UtilisateurProduit
                }));
                StockORM.Populate(produit.StockProduit);
                if (!string.IsNullOrEmpty(produit.EnchereGagnante.IdEnchere))
                {
                    EnchereORM.Populate(produit.EnchereGagnante);
                }

                //todo decomenter ici
                // CategorieORM.Populate(produit.CategorieProduit);
            }

            return(produit);
        }
Example #8
0
        public static void Populate(Enchere enchere)
        {
            // liste des encheres qui on beusoin de se faire peupler (leurs liste utilisateurs)

            if (!EnchereAlreadyInDictionary(enchere.IdEnchere))
            {
                GetEnchereById(enchere.IdEnchere);
            }

            enchere.CommissaireEnchere = _encheresDictionary[enchere.IdEnchere].CommissaireEnchere;
            enchere.LotEnchere         = _encheresDictionary[enchere.IdEnchere].LotEnchere;
            enchere.OrdreAchatEnchere  = _encheresDictionary[enchere.IdEnchere].OrdreAchatEnchere;
            enchere.UtilisateurEnchere = _encheresDictionary[enchere.IdEnchere].UtilisateurEnchere;
        }
Example #9
0
        public ListeEncheresView(Window win = null, List <Enchere> selectedEncheres = null)
        {
            InitializeComponent();

            _selectedEncheres = selectedEncheres;

            if (selectedEncheres == null)
            {
                selectMode.Visibility = Visibility.Collapsed;
            }


            _encheres       = new ObservableCollection <Enchere>(EnchereORM.GetAllEnchere());
            _contextEnchere = new Enchere();
            GenerateDataList();
        }
Example #10
0
 public Produit(string idProduit, Lot lotProduit, Utilisateur utilisateurProduit, Stock stockProduit,
                Enchere enchereGagnante, Categorie categorieProduit, string nomArtiste, string nomStyle, string nomProduit,
                double prixReserve, string referenceCatalogue, string description, bool isSend)
 {
     IdProduit          = idProduit;
     LotProduit         = lotProduit;
     UtilisateurProduit = utilisateurProduit;
     StockProduit       = stockProduit;
     EnchereGagnante    = enchereGagnante;
     CategorieProduit   = categorieProduit;
     NomArtiste         = nomArtiste;
     NomStyle           = nomStyle;
     NomProduit         = nomProduit;
     PrixReserve        = prixReserve;
     ReferenceCatalogue = referenceCatalogue;
     Description        = description;
     IsSend             = isSend;
 }
Example #11
0
        private void AddEnchere(object sender, RoutedEventArgs e)
        {
            var newEnchere = new Enchere();

            var window = new Window
            {
                Title         = "Ajouter une Enchere",
                SizeToContent = SizeToContent.WidthAndHeight,
                ResizeMode    = ResizeMode.NoResize,
                Background    = (SolidColorBrush) new BrushConverter().ConvertFrom("#393C43"),
                Icon          = new BitmapImage(new Uri("pack://application:,,,/ressources/CRUDimg/enchere.png",
                                                        UriKind.RelativeOrAbsolute))
            };

            window.Content = new AddEnchereView(window, newEnchere);
            window.ShowDialog();
            if (newEnchere.IdEnchere != null)
            {
                _encheres.Add(newEnchere);
            }
        }
Example #12
0
 public static void DeleteEnchere(Enchere enchere)
 {
     EnchereDAL.DeleteEnchere(enchere.IdEnchere);
 }
Example #13
0
 public static void UpadateEnchere(Enchere enchere)
 {
     EnchereDAL.UpdateEnchere(EnchereToEnchereDAO(enchere));
 }
Example #14
0
 public static void InsertOrAddNewEnchere(Enchere enchere)
 {
     EnchereDAL.InsertNewEnchere(EnchereToEnchereDAO(enchere));
 }
Example #15
0
        public async Task <IActionResult> Miser(Enchere newEnchere)
        {
            var userManager = _serviceProvider.GetRequiredService <UserManager <ApplicationUser> >();
            var userName    = await userManager.FindByNameAsync(User.Identity.Name);

            Miseur miseur = (Miseur)userName;

            if (newEnchere.MiseMax < newEnchere.Niveau)
            {
                var nextMinBid = newEnchere.Niveau + (double)bidMove;
                ModelState.AddModelError(string.Empty, "Prochain montant d'enchère valide est:$" + nextMinBid);
                return(View(newEnchere));
            }


            var objet = await _context.Objets
                        .Include(o => o.Encheres)
                        .ThenInclude(o => o.Miseur)
                        .Include(o => o.ConfigurationAdmin)
                        .Include(o => o.Acheteur)
                        .Include(o => o.Vendeur)
                        .SingleOrDefaultAsync(m => m.ObjetID == newEnchere.ObjetId);

            var newMaxBid = newEnchere.MiseMax;
            //objet.ConfigurationAdmin = _context.ConfigurationAdmins.Last();

            var pas      = objet.ConfigurationAdmin.PasGlobalEnchere;
            var encheres = objet.Encheres.ToList();

            Double[] enchereTableau = new Double[encheres.Count];
            Miseur[] lesMiseurs     = new Miseur[encheres.Count];

            var i = 0;

            foreach (Enchere item in encheres)
            {
                enchereTableau[i] = item.MiseMax;
                lesMiseurs[i]     = item.Miseur;
                i++;
            }

            var bestBid = Max(enchereTableau);
            var newBid  = 0.00;

            var msgFr = "Un autre membre a surenchérit sur l'objet.Si vous n'augmentez pas votre enchère maximum vous perdrez l'objet";
            var msgEn = "Another member outbid the object .If you do not increase your maximum bid you will lose the item";
            var msg   = msgFr;

            if (newMaxBid > bestBid)
            {
                for (int j = 0; j < encheres.Count; j++)
                {
                    //Le système surenchérit automatiquement pour tous à l'enchère maximum.
                    encheres[j].Niveau = encheres[j].MiseMax;
                    //envoyerun message aux concernés les avisant q un autre mebre a surencherit sur l'objet

                    if (encheres[j].Miseur.Langue == "en")
                    {
                        msg = msgEn;
                    }
                    notifyBiders(miseur.Email, msg);
                }

                newBid = bestBid + (double)pas;
            }
            else
            {
                for (int j = 0; j < encheres.Count; j++)
                {
                    if (newMaxBid > encheres[j].MiseMax)
                    {
                        //Le système surenchérit automatiquement pour tous à l'enchère maximum.
                        encheres[j].Niveau = encheres[j].MiseMax;
                        //envoyerun message aux concernés les avisant q un autre mebre a surencherit sur l objet

                        if (encheres[j].Miseur.Langue == "en")
                        {
                            msg = msgEn;
                        }
                        notifyBiders(miseur.Email, msg);
                    }

                    if (newMaxBid <= encheres[j].MiseMax)
                    {
                        //Le système surenchérit automatiquement pour tous à l'enchère maximum.
                        encheres[j].Niveau = ((newMaxBid + (double)pas) < encheres[j].MiseMax) ? (newMaxBid + (double)pas) : encheres[j].MiseMax;

                        //on avise le miseur actuel selon sa langue parlée
                        if (encheres[j].Miseur.Langue == "en")
                        {
                            msg = msgEn;
                        }
                        notifyBiders(miseur.Email, msg);
                    }
                }
                newBid = newMaxBid;
            }

            Miseur losingBidder = lesMiseurs[index];

            objet.Fichiers = new List <Fichier>();

            newEnchere.Niveau  = newBid;
            newEnchere.MiseMax = newMaxBid;
            newEnchere.Miseur  = miseur;

            objet.Encheres.Add(newEnchere);
            _context.Update(objet);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }