Exemplo n.º 1
0
        public ActionResult MyAssets(string id = null)
        {
            if (id == null)
            {
                id = Guid.NewGuid().ToString();
                return(RedirectToAction("New", new { id = id }));
            }

            EstadoUsuario.CurrentListPublicId = id;

            EDVMyAssets edv = new EDVMyAssets();

            SetHeadCounters();

            ViewBag.PublicID = id;
            AgenteShoppingList agente = new AgenteShoppingList();

            edv.allowEdit = agente.IsShoppingListOwner(EstadoUsuario.CurrentListPublicId, this.User.Identity == null ? null : this.User.Identity.Name);

            //Guardamos la shopping list en las de un usuario si se indica en la url
            agente.SaveListInMyListsIfProceed(this.Request, this.User.Identity, id);

            EVListSummary summ = agente.SelectListSummaryPorPublicID(id);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string itemArray = serializer.Serialize(summ.Items);

            edv.Summary            = summ;
            edv.IsShoppingListFree = agente.IsShoppingListFree(id);

            edv.ListNavMenu = new EDPVListNavMenu <Enumerados.StepsForPVPList>(Modelo.Enumerados.StepsForPVPList.MyAssets);

            return(View(edv));
        }
Exemplo n.º 2
0
        public eshSnapshot CreateStaticShoppingListFromGroup(string groupPublicID, string name, IImageResolver iresolver)
        {
            LogicaGroupLists logica = new LogicaGroupLists();
            EVListSummary    ev     = logica.SelectGroupListSummaryPorPublicID(groupPublicID, iresolver);
            eshSnapshot      snap   = new eshSnapshot();

            if (ev == null)
            {
                return(null);
            }
            snap.name         = ev.Name;
            snap.description  = ev.Description;
            snap.totalVolume  = ev.TotalVolume;
            snap.totalPrice   = ev.TotalPrice;
            snap.publicID     = Guid.NewGuid().ToString();
            snap.creationDate = System.DateTime.Now;
            foreach (var item in ev.Items)
            {
                eshSnapshotInvType sit = new eshSnapshotInvType();
                sit.typeID    = item.ItemID;
                sit.unitPrice = item.UnitPrice;
                sit.units     = item.Units;
                sit.volume    = item.Volume;
                snap.eshSnapshotInvTypes.Add(sit);
            }
            return(snap);
        }
Exemplo n.º 3
0
        public ActionResult GetList(string id)
        {
            SetHeadCounters();


            AgenteShoppingList agente = new AgenteShoppingList();
            EVListSummary      summ   = agente.SelectListSummaryPorPublicIDRead(id);

            ViewBag.PublicID = id;
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string itemArray = serializer.Serialize(summ.Items);


            EDVSummary edv = new EDVSummary();

            edv.ItemArray = itemArray;
            edv.Summary   = summ;


            if (summ.PublicID == id)
            {
                //Guardamos la shopping list en las de un usuario si se indica en la url
                agente.SaveListInMyListsIfProceed(this.Request, this.User.Identity, id);
                edv.IsShoppingListFree = agente.IsShoppingListFree(id);
                return(View("Summary", edv));
            }
            else
            {
                return(View("Public", edv));
            }
        }
Exemplo n.º 4
0
        public ActionResult MyAssets(string id = null)
        {
            if (id == null)
            {
                id = Guid.NewGuid().ToString();
                return(RedirectToAction("New", new { id = id }));
            }

            EstadoUsuario.CurrentListPublicId = id;

            EDVGroupMyAssets edv = new EDVGroupMyAssets();

            SetHeadCounters();

            ViewBag.PublicID = id;
            AgenteGroupLists agente = new AgenteGroupLists();

            edv.allowEdit = agente.IsGroupListOwner(id, this.User.Identity == null ? null : this.User.Identity.Name);

            EVListSummary summ = agente.SelectGroupListSummaryPorPublicID(id);

            edv.Summary = summ;

            edv.ListNavMenu = new EDPVListNavMenu <Enumerados.StepsForGroupList>(Modelo.Enumerados.StepsForGroupList.MyAssets);

            return(View(edv));
        }
Exemplo n.º 5
0
        public EVListSummary SelectGroupListSummaryPorPublicID(string publicID, IImageResolver imageResolver)
        {
            EveShoppingContext   contexto     = new EveShoppingContext();
            eshGroupShoppingList shoppingList = contexto.eshGroupShoppingLists.Where(sl => sl.publicID == publicID).FirstOrDefault();

            if (shoppingList == null)
            {
                return(null);
            }

            EVListSummary summary =
                new EVListSummary();

            summary.Description      = shoppingList.description;
            summary.Name             = shoppingList.name;
            summary.PublicID         = shoppingList.publicID;
            summary.ReadOnlyPublicID = null;
            summary.ShoppingListID   = shoppingList.groupShoppingListID;

            Dictionary <int, EVFittingHardware> diccHwd = new Dictionary <int, EVFittingHardware>();

            //por cada snapshot que tenemos asociado
            foreach (var snapshot in shoppingList.eshGroupShoppingListSnapshots)
            {
                summary.TotalVolume += snapshot.eshSnapshot.totalVolume;
                foreach (var item in snapshot.eshSnapshot.eshSnapshotInvTypes)
                {
                    EVFittingHardware efth = null;
                    if (diccHwd.ContainsKey(item.typeID))
                    {
                        efth             = diccHwd[item.typeID];
                        efth.Volume     += item.volume.Value;
                        efth.TotalPrice += item.unitPrice * item.units;
                        efth.Units      += item.units;
                    }
                    else
                    {
                        efth = new EVFittingHardware()
                        {
                            Name       = item.invType.typeName,
                            ItemID     = item.typeID,
                            Units      = item.units,
                            Volume     = item.volume.Value,
                            UnitVolume = item.volume.Value / item.units,
                            TotalPrice = item.unitPrice * item.units,
                            UnitPrice  = item.unitPrice,
                            ImageUrl32 = imageResolver.GetImageURL(item.typeID)
                        };
                        diccHwd.Add(efth.ItemID, efth);
                    }
                }
            }

            foreach (var item in diccHwd.Values)
            {
                summary.Items.Add(item);
            }
            return(summary);
        }
Exemplo n.º 6
0
        public ActionResult Public(string id)
        {
            AgenteShoppingList agente = new AgenteShoppingList();
            EVListSummary      summ   = agente.SelectListSummaryPorPublicIDRead(id);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string itemArray = serializer.Serialize(summ.Items);

            ViewBag.PublicID = id;

            EDVSummary edv = new EDVSummary();

            edv.ItemArray = itemArray;
            edv.Summary   = summ;

            return(View(edv));
        }
Exemplo n.º 7
0
        public eshSnapshot CreateStaticShoppingList(string publicID, string name, IImageResolver iresolver)
        {
            LogicaShoppingLists logica =
                new LogicaShoppingLists();

            EVListSummary summ = logica.SelectListSummaryPorPublicID(publicID, iresolver);

            if (summ == null)
            {
                return(null);
            }

            eshSnapshot shot = new eshSnapshot();

            shot.creationDate   = System.DateTime.Now;
            shot.shoppingListID = summ.ShoppingListID;
            shot.totalPrice     = summ.TotalPrice;
            shot.totalVolume    = summ.TotalVolume;
            shot.publicID       = Guid.NewGuid().ToString();
            shot.name           = (string.IsNullOrEmpty(name))? summ.Name:name;
            shot.description    = summ.Description;

            foreach (var item in summ.Items)
            {
                if ((item.Units) > 0)
                {
                    eshSnapshotInvType shotitem = new eshSnapshotInvType();
                    shotitem.typeID    = item.ItemID;
                    shotitem.unitPrice = item.UnitPrice;
                    shotitem.units     = item.Units;
                    shotitem.volume    = item.Volume;
                    shot.eshSnapshotInvTypes.Add(shotitem);
                }
            }
            EveShoppingContext contexto = new EveShoppingContext();

            contexto.eshSnapshots.Add(shot);
            contexto.SaveChanges();

            return(shot);
        }
Exemplo n.º 8
0
        public IList <AssetImported> ImportAssetsForListDelta(string publicId, string assets, IImageResolver imageResolver)
        {
            ImportItemListFromAssets            importer   = new ImportItemListFromAssets();
            IDictionary <string, AssetImported> diccassets = importer.ImportFrom(assets);
            List <AssetImported> salida = new List <AssetImported>();

            EVListSummary summ = this.SelectListSummaryPorPublicID(publicId, imageResolver, true);

            foreach (var item in summ.Items)
            {
                if (diccassets.ContainsKey(item.Name))
                {
                    AssetImported ai = diccassets[item.Name];
                    ai.Id         = item.ItemID;
                    ai.ImageUrl32 = item.ImageUrl32;
                    ai.Units     *= -1;
                    salida.Add(ai);
                }
            }
            return(salida);
        }
Exemplo n.º 9
0
        public ActionResult Summary(string id)
        {
            SetHeadCounters();
            this.ViewBag.PublicID = id;

            AgenteGroupLists agente = new AgenteGroupLists();
            EVListSummary    ev     = agente.SelectGroupListSummaryPorPublicID(id);
            EDVGroupSummary  edv    = new EDVGroupSummary();

            edv.Summary           = ev;
            edv.Summary.ShowDelta = false;

            IEnumerable <EVStaticList> lists = agente.SelectStaticListsHeadersByGroupId(id);

            edv.Lists             = lists;
            edv.allowEdit         = agente.IsGroupListOwner(id, this.User.Identity == null ? null : this.User.Identity.Name);
            ViewBag.AllowDelete   = false;
            ViewBag.ShowGroupInfo = true;

            edv.ListNavMenu = new EDPVListNavMenu <Enumerados.StepsForGroupList>(Modelo.Enumerados.StepsForGroupList.Summary);


            return(View(edv));
        }
Exemplo n.º 10
0
        public EVListSummary SelectListSummaryPorPublicID(string publicID, IImageResolver imageResolver, bool includeEmpty = true)
        {
            EveShoppingContext contexto     = new EveShoppingContext();
            eshShoppingList    shoppingList = contexto.eshShoppingLists.Where(sl => sl.publicID == publicID).FirstOrDefault();

            if (shoppingList == null)
            {
                return(null);
            }

            EVListSummary summary =
                new EVListSummary();

            summary.Description      = shoppingList.description;
            summary.Name             = shoppingList.name;
            summary.PublicID         = shoppingList.publicID;
            summary.ReadOnlyPublicID = shoppingList.readOnlypublicID;
            summary.ShoppingListID   = shoppingList.shoppingListID;


            IEnumerable <EVFitting> fittings = this.SelectFitsInShoppingList(publicID, imageResolver);

            Dictionary <int, EVFittingHardware> diccHwd = new Dictionary <int, EVFittingHardware>();

            //add ships
            foreach (var fit in fittings)
            {
                EVFittingHardware fw = null;
                if (diccHwd.ContainsKey(fit.ShipID))
                {
                    fw             = diccHwd[fit.ShipID];
                    fw.Units      += fit.Units;
                    fw.Volume     += fit.Units * fit.ShipVolume;
                    fw.TotalPrice += fit.ShipPrice * fit.Units;
                }
                else
                {
                    fw = new EVFittingHardware
                    {
                        Name       = fit.ShipName,
                        ItemID     = fit.ShipID,
                        Units      = fit.Units,
                        Volume     = fit.ShipVolume * fit.Units,
                        UnitVolume = fit.ShipVolume,
                        TotalPrice = fit.ShipPrice * fit.Units,
                        UnitPrice  = fit.ShipPrice,
                        ImageUrl32 = imageResolver != null?imageResolver.GetImageURL(fit.ShipID) : string.Empty
                    };
                    diccHwd.Add(fw.ItemID, fw);
                }
            }
            //add fitted hardware
            foreach (var fit in fittings)
            {
                foreach (var fw in fit.FittingHardwares)
                {
                    if (diccHwd.ContainsKey(fw.ItemID))
                    {
                        EVFittingHardware fwd = diccHwd[fw.ItemID];
                        fwd.Units      += fw.Units * fit.Units;
                        fwd.Volume     += fw.Volume * fit.Units;
                        fwd.TotalPrice += fw.TotalPrice * fit.Units;
                        //fw.UnitPrice = fw.TotalPrice;
                    }
                    else
                    {
                        fw.Units      *= fit.Units;
                        fw.Volume     *= fit.Units;
                        fw.TotalPrice *= fit.Units;
                        if (fit.Units != 0)
                        {
                            fw.UnitVolume = fw.Volume / fw.Units;
                            fw.UnitPrice  = fw.TotalPrice / fw.Units;
                        }
                        else
                        {
                            fw.UnitVolume = fw.Volume;
                            fw.UnitPrice  = fw.TotalPrice;
                        }
                        diccHwd.Add(fw.ItemID, fw);
                    }
                }
            }
            //add market items
            IEnumerable <MarketItem> marketItems = this.SelectMarketItemsEnShoppingList(publicID, imageResolver);

            foreach (var mi in marketItems)
            {
                if (diccHwd.ContainsKey(mi.ItemID))
                {
                    EVFittingHardware fwd = diccHwd[mi.ItemID];
                    fwd.Units      += mi.Units;
                    fwd.Volume     += mi.Volume;
                    fwd.TotalPrice += mi.TotalPrice;
                }
                else
                {
                    EVFittingHardware fwd = new EVFittingHardware();
                    fwd.ImageUrl32 = mi.ImageUrl32;
                    fwd.ItemID     = mi.ItemID;
                    fwd.Name       = mi.Name;
                    fwd.TotalPrice = mi.TotalPrice;
                    fwd.UnitPrice  = mi.UnitPrice;
                    fwd.Units      = mi.Units;
                    fwd.Volume     = mi.Volume;
                    fwd.UnitVolume = mi.Volume / mi.Units;
                    diccHwd.Add(fwd.ItemID, fwd);
                }
            }

            // Update summary changes
            IEnumerable <eshShoppingListSummInvType> summInvs =
                contexto.eshShoppingListSummInvTypes.Where(sls => sls.shoppingListID == summary.ShoppingListID);

            foreach (var summInv in summInvs)
            {
                if (!diccHwd.ContainsKey(summInv.typeID))
                {
                    //if the item is not in the items dictionary, it doesnt exist anymore in the list, so we delete the delta
                    contexto.eshShoppingListSummInvTypes.Remove(summInv);
                }
                else
                {
                    EVFittingHardware fwd = diccHwd[summInv.typeID];
                    if ((summInv.delta < 0) && (summInv.delta * -1 > fwd.Units))
                    {
                        summInv.delta = (short)(fwd.Units * -1);
                    }
                    fwd.TotalPrice += summInv.delta * fwd.UnitPrice;
                    fwd.Volume     += (fwd.Volume / fwd.Units) * summInv.delta;
                    fwd.Units      += summInv.delta;
                    fwd.Delta       = summInv.delta;
                }
            }

            foreach (var item in diccHwd.Values)
            {
                if (includeEmpty || (item.Units > 0))
                {
                    summary.Items.Add(item);
                    summary.TotalPrice  += item.TotalPrice;
                    summary.TotalVolume += item.Volume;
                }
            }

            contexto.SaveChanges();



            return(summary);
        }