Esempio n. 1
0
        public bool AddClassified(Classified classified)
        {
            object remoteValue = DoRemote(classified);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue != null && (bool) remoteValue;

            if (GetUserProfile(classified.CreatorUUID) == null)
                return false;
            string keywords = classified.Description;
            if (keywords.Length > 512)
                keywords = keywords.Substring(keywords.Length - 512, 512);
            //It might be updating, delete the old
            QueryFilter filter = new QueryFilter();
            filter.andFilters["ClassifiedUUID"] = classified.ClassifiedUUID;
            GD.Delete("userclassifieds", filter);
            List<object> values = new List<object>
                                      {
                                          classified.Name,
                                          classified.Category,
                                          classified.SimName,
                                          classified.CreatorUUID,
                                          classified.ScopeID,
                                          classified.ClassifiedUUID,
                                          OSDParser.SerializeJsonString(classified.ToOSD()),
                                          classified.PriceForListing,
                                          keywords
                                      };
            return GD.Insert("userclassifieds", values.ToArray());
        }
Esempio n. 2
0
 public void Save(Classified classified)
 {
     using (var uow = unitOfWorkFactory())
     {
         uow.Classifieds.Save(classified);
         uow.SubmitChanges();
     }
 }
 public static ClassifiedRepresentation Map(Classified classified)
 {
     return new ClassifiedRepresentation
                {
                    Id = classified.Id,
                    Description = classified.Description,
                    Name = classified.Name,
                    //Location = classified.Location,
                    //Items = classified.Items.Select(i => new classifiedItemRepresentation
                    //                                    {
                    //                                        Name = i.Product.Name,
                    //                                        Preferences = i.Preferences.ToDictionary(p => p.Key, p => p.Value),
                    //                                        Quantity = i.Quantity
                    //                                    }).ToList(),
                    //Links = GetLinks(classified).ToList()   
                };
     
 }
Esempio n. 4
0
        public Classified GetClassified(UUID queryClassifiedID)
        {
            Dictionary <string, object> where = new Dictionary <string, object>(1);
            where["ClassifiedUUID"]           = queryClassifiedID;

            List <string> query = GD.Query(new string[1] {
                "*"
            }, "userclassifieds", new QueryFilter
            {
                andFilters = where
            }, null, null, null);

            if (query.Count < 6)
            {
                return(null);
            }
            Classified classified = new Classified();

            classified.FromOSD((OSDMap)OSDParser.DeserializeJson(query[5]));
            return(classified);
        }
        /// <summary>
        /// Gets all classifieds in the given region
        /// </summary>
        /// <param name="regionName"></param>
        /// <returns></returns>
        public Classified[] GetClassifiedsInRegion(string regionName)
        {
            List <Classified> Classifieds = new List <Classified>();
            List <string>     retVal      = GD.Query("SimName", regionName, "userclassifieds", "*");

            if (retVal.Count == 0)
            {
                return(Classifieds.ToArray());
            }

            Classified classified = new Classified();

            for (int i = 0; i < retVal.Count; i += 6)
            {
                //Pull the classified out of OSD
                classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5]));
                Classifieds.Add(classified);
                classified = new Classified();
            }
            return(Classifieds.ToArray());
        }
Esempio n. 6
0
        public List <Classified> GetClassifieds(UUID ownerID)
        {
            Dictionary <string, object> where = new Dictionary <string, object>(1);
            where["OwnerUUID"] = ownerID;

            List <string> query = GD.Query(new string[1] {
                "*"
            }, "userclassifieds", new QueryFilter
            {
                andFilters = where
            }, null, null, null);

            List <Classified> classifieds = new List <Classified>();

            for (int i = 0; i < query.Count; i += 6)
            {
                Classified classified = new Classified();
                classified.FromOSD((OSDMap)OSDParser.DeserializeJson(query[i + 5]));
                classifieds.Add(classified);
            }
            return(classifieds);
        }
Esempio n. 7
0
        private void timerCapture_Tick(object sender, EventArgs e)
        {
            string path = _classifyMode ? _savePath : $@"{_savePath}\{DateTime.Now:yyyyMMddHHmmss.fff}.jpg";

            //_bmp.Save(path);
            SaveResizedBitmap(path, 0.5f);

            if (_classifyMode)
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    // predict the webcam image.
                    MLContext mlContext  = new MLContext(seed: 1);
                    var predictionResult = Classifier.GetSingleImagePrediction(mlContext, ImageClassification.IO.DataLoader.GetPipeline(mlContext, _pipelineZip), ImageClassification.IO.DataLoader.GetModel(mlContext, _modelZip), _savePath);
                    Classified?.Invoke(this, predictionResult);
                    // overray
                    //_frame.PutText($"{predictionResult.PredictedLabel} {predictionResult.Score:P}", new OpenCvSharp.Point(10, 10), HersheyFonts.HersheyPlain, 10, new Scalar(0), 2);
                });
            }
            _count++;
            Captured?.Invoke(this, new CapturedInfo(_count, path));
        }
Esempio n. 8
0
        public bool AddClassified(Classified classified)
        {
            if (GetUserProfile(classified.CreatorUUID) == null)
            {
                return(false);
            }
            //It might be updating, delete the old
            GD.Delete("userclassifieds", new string[1] {
                "ClassifiedUUID"
            }, new object[1] {
                classified.ClassifiedUUID
            });
            List <object> values = new List <object>();

            values.Add(classified.Name);
            values.Add(classified.Category);
            values.Add(classified.SimName);
            values.Add(classified.CreatorUUID);
            values.Add(classified.ClassifiedUUID);
            values.Add(OSDParser.SerializeJsonString(classified.ToOSD()));
            return(GD.Insert("userclassifieds", values.ToArray()));
        }
Esempio n. 9
0
        public PartialViewResult CategoryChoosingPartial(int?id)
        {
            ICollection <Category> children, children2;
            Dictionary <string, ICollection <Category> > Children = new Dictionary <string, ICollection <Category> >();

            var query = db.Categories.Where(p => p.CategoryFatherID == null).ToList();

            foreach (var i in query)
            {
                children         = hasChildren(i.CategoryID);
                Children[i.Name] = null;
                if (children != null)
                {
                    Children[i.Name] = children;
                    foreach (var j in children)
                    {
                        children2        = hasChildren(j.CategoryID);
                        Children[j.Name] = null;
                        if (children2 != null)
                        {
                            Children[j.Name] = children2;
                        }
                    }
                }
            }

            ViewBag.Children = Children;


            if (id != null)
            {
                Classified c = db.Classifieds.Find(id);
                ViewBag.cPath = c.CategoryPath;
                ViewBag.cn    = c.Category.Name;
            }


            return(PartialView("CategoryChoosingPartial", query));
        }
Esempio n. 10
0
        public bool AddClassified(Classified classified)
        {
            object remoteValue = DoRemote(classified);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return(remoteValue != null && (bool)remoteValue);
            }

            if (GetUserProfile(classified.CreatorUUID) == null)
            {
                return(false);
            }
            string keywords = classified.Description;

            if (keywords.Length > 512)
            {
                keywords = keywords.Substring(keywords.Length - 512, 512);
            }
            //It might be updating, delete the old
            QueryFilter filter = new QueryFilter();

            filter.andFilters["ClassifiedUUID"] = classified.ClassifiedUUID;
            GD.Delete("userclassifieds", filter);
            List <object> values = new List <object>
            {
                classified.Name,
                classified.Category,
                classified.SimName,
                classified.CreatorUUID,
                classified.ScopeID,
                classified.ClassifiedUUID,
                OSDParser.SerializeJsonString(classified.ToOSD()),
                classified.PriceForListing,
                keywords
            };

            return(GD.Insert("userclassifieds", values.ToArray()));
        }
Esempio n. 11
0
 public List <Classified> GetClassifieds(UUID ownerID)
 {
     try
     {
         List <string> serverURIs =
             m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(ownerID.ToString(),
                                                                                     "RemoteServerURI");
         foreach (string url in serverURIs)
         {
             OSDMap map = new OSDMap();
             map["Method"]      = "getclassifieds";
             map["PrincipalID"] = ownerID;
             OSDMap response = WebUtils.PostToService(url + "osd", map, true, true);
             if (response["_Result"].Type == OSDType.Map)
             {
                 OSDMap responsemap = (OSDMap)response["_Result"];
                 if (responsemap.ContainsKey("Result"))
                 {
                     List <Classified> list  = new List <Classified>();
                     OSDArray          picks = (OSDArray)responsemap["Result"];
                     foreach (OSD o in picks)
                     {
                         Classified info = new Classified();
                         info.FromOSD((OSDMap)o);
                         list.Add(info);
                     }
                     return(list);
                 }
                 return(new List <Classified>());
             }
         }
     }
     catch (Exception e)
     {
         MainConsole.Instance.DebugFormat("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e);
     }
     return(null);
 }
        public Classified GetClassified(UUID queryClassifiedID)
        {
            if (m_doRemoteOnly)
            {
                object remoteValue = DoRemote(queryClassifiedID);
                return(remoteValue != null ? (Classified)remoteValue : null);
            }

            QueryFilter filter = new QueryFilter();

            filter.andFilters["ClassifiedUUID"] = queryClassifiedID;

            List <string> query = GD.Query(new[] { "*" }, m_userClassifiedsTable, filter, null, null, null);

            if (query.Count < 9)
            {
                return(null);
            }

            Classified classified = new Classified();

            classified.FromOSD((OSDMap)OSDParser.DeserializeJson(query[6]));
            return(classified);
        }
        public List <Classified> GetClassifieds(UUID ownerID)
        {
            if (m_doRemoteOnly)
            {
                object remoteValue = DoRemote(ownerID);
                return(remoteValue != null ? (List <Classified>)remoteValue : new List <Classified> ());
            }

            QueryFilter filter = new QueryFilter();

            filter.andFilters["OwnerUUID"] = ownerID;

            List <string> query = GD.Query(new[] { "*" }, m_userClassifiedsTable, filter, null, null, null);

            List <Classified> classifieds = new List <Classified>();

            for (int i = 0; i < query.Count; i += 9)
            {
                Classified classified = new Classified();
                classified.FromOSD((OSDMap)OSDParser.DeserializeJson(query[i + 6]));
                classifieds.Add(classified);
            }
            return(classifieds);
        }
        public ActionResult CategoryInfo(CategryModel info)
        {
            var clas = _readOnlyRepository.GetAll <Classified>().ToList();

            info.Clasificados = new List <Classified>(clas.Count + 1);
            foreach (var c in clas.Where(c => c.Categoria == info.Categoria))
            {
                if (String.IsNullOrEmpty(c.UrlImg0))
                {
                    c.UrlImg0 =
                        "none";
                }

                if (String.IsNullOrEmpty(c.UrlImg1))
                {
                    c.UrlImg1 =
                        "none";
                }

                if (String.IsNullOrEmpty(c.UrlImg2))
                {
                    c.UrlImg2 =
                        "none";
                }

                if (String.IsNullOrEmpty(c.UrlImg3))
                {
                    c.UrlImg3 =
                        "none";
                }

                if (String.IsNullOrEmpty(c.UrlImg4))
                {
                    c.UrlImg4 =
                        "none";
                }

                if (String.IsNullOrEmpty(c.UrlImg5))
                {
                    c.UrlImg5 =
                        "none";
                }
                if (String.IsNullOrEmpty(c.UrlVideo))
                {
                    c.UrlVideo = "none";
                }

                info.Clasificados.Add(c);
                {
                    if (info.Clasificados == null)
                    {
                        var clsif = new Classified
                        {
                            Categoria     = "none",
                            FechaCreacion = "none",
                            Id            = 0,
                            Archived      = false,
                            IdUsuario     = 0,
                            Descripcion   = "none",
                            Negocio       = "none",
                            Recomendado   = 0,
                            UrlImg0       = "none",
                            Precio        = "none",
                            Titulo        = "none",
                            UrlImg1       = "nonce",
                            UrlVideo      = "none",
                            UrlImg2       = "none",
                            UrlImg3       = "none",
                            UrlImg4       = "none",
                            UrlImg5       = "none",
                            Visitas       = 0
                        };
                        info.Clasificados.Add(clsif);

                        this.AddNotification("No existen clasificados de esa categoria.", NotificationType.Info);
                        return(View(info));
                    }
                }
            }
            return(View(info));
        }
        private void ValidarCampos(Classified detalle, DetalleCategoryModel detail, string defaultUrl)
        {
            switch (RemoteFileExists(detalle.UrlImg0))
            {
            case true:
                detail.UrlImg0 = detalle.UrlImg0;
                break;

            case false:
                detail.UrlImg0 = defaultUrl;
                break;
            }
            switch (RemoteFileExists(detalle.UrlImg1))
            {
            case true:
                detail.UrlImg1 = detalle.UrlImg1;
                break;

            case false:
                detail.UrlImg1 = defaultUrl;
                break;
            }
            switch (RemoteFileExists(detalle.UrlImg2))
            {
            case true:
                detail.UrlImg2 = detalle.UrlImg2;
                break;

            case false:
                detail.UrlImg2 = defaultUrl;
                break;
            }
            switch (RemoteFileExists(detalle.UrlImg3))
            {
            case true:
                detail.UrlImg3 = detalle.UrlImg3;
                break;

            case false:
                detail.UrlImg3 = defaultUrl;
                break;
            }
            switch (RemoteFileExists(detalle.UrlImg4))
            {
            case true:
                detail.UrlImg4 = detalle.UrlImg4;
                break;

            case false:
                detail.UrlImg4 = defaultUrl;
                break;
            }
            switch (RemoteFileExists(detalle.UrlImg5))
            {
            case true:
                detail.UrlImg5 = detalle.UrlImg5;
                break;

            case false:
                detail.UrlImg5 = defaultUrl;
                break;
            }
            switch (RemoteFileExists(detalle.UrlVideo))
            {
            case true:
                detail.UrlVideo = detalle.UrlVideo;
                break;

            case false:
                detail.UrlVideo = "none";
                break;
            }
        }
        public int Delete(int id)
        {
            Classified classified = database.Single <Classified>("SELECT * FROM classifieds WHERE id=" + id);

            return(database.Delete(classified));
        }
        private static void GetClasificadosRecomendados(IEnumerable <Classified> desc1, IndexModel index)
        {
            Classified bienesRaices = null;
            Classified automovil    = null;
            Classified nautica      = null;
            Classified computacion  = null;
            Classified joyeria      = null;
            Classified musica       = null;
            Classified arte         = null;
            Classified hogar        = null;
            Classified deportes     = null;
            Classified telefonia    = null;
            Classified animales     = null;

            foreach (var s in desc1)
            {
                switch (s.Categoria)
                {
                case "Bienes Raices":
                    if (bienesRaices == null)
                    {
                        bienesRaices = new Classified();
                    }
                    if (bienesRaices.Recomendado < s.Recomendado)
                    {
                        bienesRaices = s;
                    }

                    break;

                case "Automovil":
                    if (automovil == null)
                    {
                        automovil = new Classified();
                    }
                    if (automovil.Recomendado < s.Recomendado)
                    {
                        automovil = s;
                    }

                    break;

                case "Nautica":
                    if (nautica == null)
                    {
                        nautica = new Classified();
                    }
                    if (nautica.Recomendado < s.Recomendado)
                    {
                        nautica = s;
                    }

                    break;

                case "Computación":
                    if (computacion == null)
                    {
                        computacion = new Classified();
                    }
                    if (computacion.Recomendado < s.Recomendado)
                    {
                        computacion = s;
                    }

                    break;

                case "Joyería":
                    if (joyeria == null)
                    {
                        joyeria = new Classified();
                    }
                    if (joyeria.Recomendado < s.Recomendado)
                    {
                        joyeria = s;
                    }

                    break;

                case "Música":
                    if (musica == null)
                    {
                        musica = new Classified();
                    }
                    if (musica.Recomendado < s.Recomendado)
                    {
                        musica = s;
                    }

                    break;

                case "Arte":
                    if (arte == null)
                    {
                        arte = new Classified();
                    }
                    if (arte.Recomendado < s.Recomendado)
                    {
                        arte = s;
                    }

                    break;

                case "Hogar":
                    if (hogar == null)
                    {
                        hogar = new Classified();
                    }
                    if (hogar.Recomendado < s.Recomendado)
                    {
                        hogar = s;
                    }

                    break;

                case "Deportes":
                    if (deportes == null)
                    {
                        deportes = new Classified();
                    }
                    if (deportes.Recomendado < s.Recomendado)
                    {
                        deportes = s;
                    }

                    break;

                case "Telefonía":
                    if (telefonia == null)
                    {
                        telefonia = new Classified();
                    }
                    if (telefonia.Recomendado < s.Recomendado)
                    {
                        telefonia = s;
                    }

                    break;

                case "Animales":
                    if (animales == null)
                    {
                        animales = new Classified();
                    }
                    if (animales.Recomendado < s.Recomendado)
                    {
                        animales = s;
                    }

                    break;
                }
            }

            if (bienesRaices != null)
            {
                index.ClasificadosRecomendados.Add(bienesRaices);
            }
            if (automovil != null)
            {
                index.ClasificadosRecomendados.Add(automovil);
            }
            if (nautica != null)
            {
                index.ClasificadosRecomendados.Add(nautica);
            }
            if (computacion != null)
            {
                index.ClasificadosRecomendados.Add(computacion);
            }
            if (joyeria != null)
            {
                index.ClasificadosRecomendados.Add(joyeria);
            }
            if (musica != null)
            {
                index.ClasificadosRecomendados.Add(musica);
            }
            if (arte != null)
            {
                index.ClasificadosRecomendados.Add(arte);
            }
            if (deportes != null)
            {
                index.ClasificadosRecomendados.Add(deportes);
            }
            if (hogar != null)
            {
                index.ClasificadosRecomendados.Add(hogar);
            }
            if (telefonia != null)
            {
                index.ClasificadosRecomendados.Add(telefonia);
            }
            if (animales != null)
            {
                index.ClasificadosRecomendados.Add(animales);
            }
        }
        /// <summary>Process an incoming packet and raise the appropriate events</summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The EventArgs object containing the packet data</param>
        protected void DirClassifiedReplyHandler(object sender, PacketReceivedEventArgs e)
        {
            if (m_DirClassifieds != null)
            {
                DirClassifiedReplyPacket reply = (DirClassifiedReplyPacket)e.Packet;
                List<Classified> classifieds = new List<Classified>();

                foreach (DirClassifiedReplyPacket.QueryRepliesBlock block in reply.QueryReplies)
                {
                    Classified classified = new Classified();

                    classified.CreationDate = Utils.UnixTimeToDateTime(block.CreationDate);
                    classified.ExpirationDate = Utils.UnixTimeToDateTime(block.ExpirationDate);
                    classified.Flags = (ClassifiedFlags)block.ClassifiedFlags;
                    classified.ID = block.ClassifiedID;
                    classified.Name = Utils.BytesToString(block.Name);
                    classified.Price = block.PriceForListing;

                    classifieds.Add(classified);
                }

                OnDirClassifieds(new DirClassifiedsReplyEventArgs(classifieds));
            }
        }
Esempio n. 19
0
        public ActionResult Edit([Bind(Include = "ClassifiedID,UserID,Name,Description,CategoryID,DateAdded,Price,State,Counter,Reported")] Classified classified, AllAtributesModel aam, Location l, HttpPostedFileBase upload0, HttpPostedFileBase upload1, HttpPostedFileBase upload2, HttpPostedFileBase upload3)
        {
            if (ModelState.IsValid)
            {
                ViewBag.badWord = consistBadWord(classified.Description);
                if (ViewBag.badWord != "")
                {
                    return(View("BadWord"));
                }

                string pom = db.Categories.Where(p => p.CategoryID == classified.CategoryID).Select(p => p.Name).First().ToString();
                classified.CategoryPath = categoryPath(pom);

                db.Entry(classified).State = EntityState.Modified;
                db.SaveChanges();



                ClassifiedLocation cl  = db.ClassifiedLocations.Where(p => p.ClassifiedID == classified.ClassifiedID).First();
                string             lid = db.Locations.Where(p => p.LocationName == l.LocationName).Select(p => p.LocationID).First().ToString();
                cl.LocationID = Int32.Parse(lid);
                db.SaveChanges();



                if (upload0 != null)
                {
                    //remove old
                    var    old       = findOld(classified.ClassifiedID, "upload0");
                    var    photoName = old.Path;
                    string fullPath  = Request.MapPath(photoName);

                    if (!old.Path.Equals("default.jpg"))
                    {
                        System.IO.File.Delete(fullPath);

                        db.Photos.Remove(old);
                        db.SaveChanges();
                        //add new

                        Photo p = new Photo();
                        p.ClassifiedID = classified.ClassifiedID;

                        //pelny sciezka do pliku
                        var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload0.jpg");
                        //zapis
                        upload0.SaveAs(path);

                        p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload0.jpg";
                        p.MainPhoto = true;

                        db.Photos.Add(p);
                        db.SaveChanges();
                    }


                    else
                    {
                        //add new

                        //pelny sciezka do pliku
                        var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload0.jpg");
                        //zapis
                        upload0.SaveAs(path);

                        old.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload0.jpg";
                        old.MainPhoto = true;

                        db.SaveChanges();
                    }
                }
                else
                {
                }

                if (upload1 != null)
                {
                    //remove old
                    var old = findOld(classified.ClassifiedID, "upload1");
                    if (old != null)
                    {
                        var    photoName = old.Path;
                        string fullPath  = Request.MapPath(photoName);

                        System.IO.File.Delete(fullPath);

                        db.Photos.Remove(old);
                        db.SaveChanges();

                        //add new
                    }

                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;
                    //pelny sciezka do pliku
                    var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload1.jpg");
                    //zapis
                    upload1.SaveAs(path);

                    p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload1.jpg";
                    p.MainPhoto = false;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }

                if (upload2 != null)
                {
                    //remove old
                    var old = findOld(classified.ClassifiedID, "upload2");
                    if (old != null)
                    {
                        var    photoName = old.Path;
                        string fullPath  = Request.MapPath(photoName);

                        System.IO.File.Delete(fullPath);

                        db.Photos.Remove(old);
                        db.SaveChanges();

                        //add new
                    }


                    //add new

                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;

                    //pelny sciezka do pliku
                    var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload2.jpg");
                    //zapis
                    upload2.SaveAs(path);

                    p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload2.jpg";
                    p.MainPhoto = false;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }

                if (upload3 != null)
                {
                    //remove old
                    var old = findOld(classified.ClassifiedID, "upload3");
                    if (old != null)
                    {
                        var    photoName = old.Path;
                        string fullPath  = Request.MapPath(photoName);

                        System.IO.File.Delete(fullPath);

                        db.Photos.Remove(old);
                        db.SaveChanges();

                        //add new
                    }


                    //add new
                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;

                    //pelny sciezka do pliku
                    var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload3.jpg");
                    //zapis
                    upload3.SaveAs(path);

                    p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload3.jpg";
                    p.MainPhoto = false;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }



                var list2 = db.ClassifiedAttributes.Where(p => p.ClassifiedID == classified.ClassifiedID).ToList();
                foreach (var i in list2)
                {
                    db.ClassifiedAttributes.Remove(i);
                }
                db.SaveChanges();

                var list = giveMeSelectedAttributes(classified.CategoryID);
                foreach (string s in list)
                {
                    ClassifiedAttribute ca = new ClassifiedAttribute();
                    ca.ClassifiedID = classified.ClassifiedID;
                    string ss  = HomeController.whiteSpacesAgain(s);
                    string aid = db.Attributes.Where(p => p.Name == ss).Select(p => p.AttributeID).First().ToString();
                    ca.AttributeID = Int32.Parse(aid);
                    switch (s)
                    {
                    case "fuel": ca.Value = aam.fuel; break;

                    case "Engine_power": ca.Value = aam.Engine_power.ToString(); break;

                    case "Engine_capacity": ca.Value = aam.Enginie_capacity.ToString(); break;

                    case "Body_type": ca.Value = aam.Body_type; break;

                    case "Transmission": ca.Value = aam.Transmission; break;

                    case "Country_of_origin": ca.Value = aam.Country_of_origin; break;

                    case "Mileage": ca.Value = aam.Mileage.ToString(); break;

                    case "Year": ca.Value = aam.Year.ToString(); break;

                    case "Color": ca.Value = aam.Color; break;

                    case "Number_of_pages": ca.Value = aam.Number_of_pages.ToString(); break;

                    case "Publication_Year": ca.Value = aam.Publication_Year.ToString(); break;
                    }

                    db.ClassifiedAttributes.Add(ca);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Name", classified.CategoryID);
            ViewBag.UserID     = new SelectList(db.Users, "Id", "Email", classified.UserID);
            return(View(classified));
        }
Esempio n. 20
0
 public void DeleteClassified(Classified classified)
 {
     _context.Classifieds.Remove(classified);
     _context.SaveChanges();
 }
Esempio n. 21
0
        public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName,
            string queryDescription, UUID queryParcelID,
            uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
            byte queryclassifiedFlags,
            int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
                return; //Just fail

            IScheduledMoneyModule scheduledMoneyModule = p.Scene.RequestModuleInterface<IScheduledMoneyModule>();
            IMoneyModule moneyModule = p.Scene.RequestModuleInterface<IMoneyModule>();
            Classified classcheck = ProfileFrontend.GetClassified(queryclassifiedID);
            if (((queryclassifiedFlags & 32) != 32) && moneyModule != null)
            {
                //Single week
                if (!moneyModule.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified", TransactionType.ClassifiedCharge))
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }
            else if (scheduledMoneyModule != null)
            {
                //Auto-renew
                if (classcheck != null)
                    scheduledMoneyModule.RemoveFromScheduledCharge("Classified" + queryclassifiedID);

                if (!scheduledMoneyModule.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified (" + queryclassifiedID +")",
                    7, TransactionType.ClassifiedCharge, "Classified" + queryclassifiedID, true))
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }

            UUID creatorUUID = remoteClient.AgentId;
            UUID classifiedUUID = queryclassifiedID;
            uint category = queryCategory;
            string name = queryName;
            string description = queryDescription;
            uint parentestate = queryParentEstate;
            UUID snapshotUUID = querySnapshotID;
            string simname = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos = queryGlobalPos;
            byte classifiedFlags = queryclassifiedFlags;
            int classifiedPrice = queryclassifiedPrice;

            UUID parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement =
                remoteClient.Scene.RequestModuleInterface<IParcelManagementModule>();
            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.GlobalID;
                }
            }

            uint creationdate = (uint) Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint) Util.UnixTimeSinceEpoch() + (365*24*60*60);

            Classified classified = new Classified
                                        {
                                            ClassifiedUUID = classifiedUUID,
                                            CreatorUUID = creatorUUID,
                                            CreationDate = creationdate,
                                            ExpirationDate = expirationdate,
                                            Category = category,
                                            Name = name,
                                            Description = description,
                                            ParcelUUID = parceluuid,
                                            ParentEstate = parentestate,
                                            SnapshotUUID = snapshotUUID,
                                            SimName = simname,
                                            GlobalPos = globalpos,
                                            ParcelName = parcelname,
                                            ClassifiedFlags = classifiedFlags,
                                            PriceForListing = classifiedPrice,
                                            ScopeID = remoteClient.ScopeID
                                        };

            ProfileFrontend.AddClassified(classified);
        }
Esempio n. 22
0
    public void TestClassyExtension()
    {
        Classified classy = new Classified();

        classy.TestExtensionMethod();
    }
 public void Remove(Classified classifiedIn) =>
 _classifieds.DeleteOne(classified => classified.Id == classifiedIn.Id);
 public void Update(string id, Classified classifiedIn) =>
 _classifieds.ReplaceOne(classified => classified.Id == id, classifiedIn);
 public Classified Create(Classified classified)
 {
     _classifieds.InsertOne(classified);
     return(classified);
 }
Esempio n. 26
0
        public Classified GetClassified(UUID queryClassifiedID)
        {
            object remoteValue = DoRemote(queryClassifiedID);
            if (remoteValue != null || m_doRemoteOnly)
                return (Classified) remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ClassifiedUUID"] = queryClassifiedID;

            List<string> query = GD.Query(new[] {"*"}, "userclassifieds", filter, null, null, null);

            if (query.Count < 9)
            {
                return null;
            }
            Classified classified = new Classified();
            classified.FromOSD((OSDMap) OSDParser.DeserializeJson(query[6]));
            return classified;
        }
Esempio n. 27
0
 public bool AddClassified(Classified classified)
 {
     return(false);
 }
Esempio n. 28
0
        public List<Classified> GetClassifieds(UUID ownerID)
        {
            object remoteValue = DoRemote(ownerID);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<Classified>) remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["OwnerUUID"] = ownerID;

            List<string> query = GD.Query(new[] {"*"}, "userclassifieds", filter, null, null, null);

            List<Classified> classifieds = new List<Classified>();
            for (int i = 0; i < query.Count; i += 9)
            {
                Classified classified = new Classified();
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(query[i + 6]));
                classifieds.Add(classified);
            }
            return classifieds;
        }
Esempio n. 29
0
        public IActionResult CreateClassified(Classified classified)
        {
            var newClassified = _classifiedsService.CreateClassified(classified);

            return(CreatedAtRoute("GetClassified", new { newClassified.Id }, newClassified));
        }
Esempio n. 30
0
        private void DirClassifiedReplyHandler(Packet packet, Simulator simulator)
        {
            if (OnClassifiedReply != null)
            {
                DirClassifiedReplyPacket reply = (DirClassifiedReplyPacket)packet;
                List<Classified> classifieds = new List<Classified>();

                foreach (DirClassifiedReplyPacket.QueryRepliesBlock block in reply.QueryReplies)
                {
                    Classified classified = new Classified();

                    classified.CreationDate = Helpers.UnixTimeToDateTime(block.CreationDate);
                    classified.ExpirationDate = Helpers.UnixTimeToDateTime(block.ExpirationDate);
                    classified.Flags = block.ClassifiedFlags;
                    classified.ID = block.ClassifiedID;
                    classified.Name = Helpers.FieldToUTF8String(block.Name);
                    classified.Price = block.PriceForListing;

                    classifieds.Add(classified);
                }

                try { OnClassifiedReply(classifieds); }
                catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); }
            }
        }
Esempio n. 31
0
 public IActionResult DeleteClassified(Classified classified)
 {
     _classifiedsService.DeleteClassified(classified);
     return(Ok());
 }
Esempio n. 32
0
        protected override void Seed(ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            Models.IdentityManager im = new Models.IdentityManager();
            if (!im.RoleExists("Admin"))
            {
                im.CreateRole("Admin");
            }
            if (!im.RoleExists("User"))
            {
                im.CreateRole("User");
            }

            var  passwordHash = new PasswordHasher();
            User u            = new User();

            u.Email    = "*****@*****.**";
            u.UserName = "******";
            //u.Nick = "slightom";
            u.PasswordHash  = passwordHash.HashPassword("Slightomp+");
            u.SecurityStamp = Guid.NewGuid().ToString();
            context.Users.AddOrUpdate(p => p.UserName, u);
            context.SaveChanges();
            im.AddUserToRoleByUsername("slightom", "User");

            u          = new User();
            u.Email    = "*****@*****.**";
            u.UserName = "******";
            //u.Nick = "witek15";
            u.PasswordHash  = passwordHash.HashPassword("Witek15p+");
            u.SecurityStamp = Guid.NewGuid().ToString();
            context.Users.AddOrUpdate(p => p.UserName, u);
            context.SaveChanges();
            im.AddUserToRoleByUsername("witek15", "User");

            u          = new User();
            u.Email    = "*****@*****.**";
            u.UserName = "******";
            //u.Nick = "wiktor500";
            u.PasswordHash  = passwordHash.HashPassword("Wiktor500p+");
            u.SecurityStamp = Guid.NewGuid().ToString();
            context.Users.AddOrUpdate(p => p.UserName, u);
            context.SaveChanges();
            im.AddUserToRoleByUsername("wiktor500", "User");

            u          = new User();
            u.Email    = "*****@*****.**";
            u.UserName = "******";
            //u.Nick = "jola17";
            u.PasswordHash  = passwordHash.HashPassword("Jola17p+");
            u.SecurityStamp = Guid.NewGuid().ToString();
            context.Users.AddOrUpdate(p => p.UserName, u);
            context.SaveChanges();
            im.AddUserToRoleByUsername("jola17", "User");

            u          = new User();
            u.Email    = "*****@*****.**";
            u.UserName = "******";
            //u.Nick = "admin1";
            u.PasswordHash  = passwordHash.HashPassword("Admin1p+");
            u.SecurityStamp = Guid.NewGuid().ToString();
            context.Users.AddOrUpdate(p => p.UserName, u);
            context.SaveChanges();
            im.AddUserToRoleByUsername("admin1", "Admin");



            BannedWord b = new BannedWord();

            b.Name = "krucafuks";
            context.BannedWords.AddOrUpdate(p => p.Name, b);
            context.SaveChanges();

            b      = new BannedWord();
            b.Name = "psia kość".ToString();
            context.BannedWords.AddOrUpdate(p => p.Name, b);
            context.SaveChanges();

            b      = new BannedWord();
            b.Name = "kurka wodna".ToString();
            context.BannedWords.AddOrUpdate(p => p.Name, b);
            context.SaveChanges();

            b      = new BannedWord();
            b.Name = "patałach".ToString();
            context.BannedWords.AddOrUpdate(p => p.Name, b);
            context.SaveChanges();

            b      = new BannedWord();
            b.Name = "motyla noga".ToString();
            context.BannedWords.AddOrUpdate(p => p.Name, b);
            context.SaveChanges();

            b      = new BannedWord();
            b.Name = "cholercia".ToString();
            context.BannedWords.AddOrUpdate(p => p.Name, b);
            context.SaveChanges();



            AdminMessage am = new AdminMessage();

            am.Title = "Wesołych Świąt!";
            am.Text  = "Administratorzy witryny MyOLX Życzą wszystkim użytkownikom Wesołych Świąt!";
            am.Date  = new DateTime(2016, 12, 20, 10, 10, 10);
            context.AdminMessages.AddOrUpdate(p => p.Title, am);



            string ids, idr;

            ids = context.Users.Where(n => n.UserName == "witek15").Select(n => n.Id).FirstOrDefault();
            idr = context.Users.Where(n => n.UserName == "jola17").Select(n => n.Id).FirstOrDefault();
            Message m = new Message();

            m.SenderID   = ids;
            m.ReceiverID = idr;
            m.Text       = "cześć";
            m.Date       = new DateTime(2016, 11, 20, 10, 10, 10);
            m.Read       = true;
            context.Messages.AddOrUpdate(p => p.Date, m);
            context.SaveChanges();

            ids          = context.Users.Where(n => n.UserName == "jola17").Select(n => n.Id).FirstOrDefault();
            idr          = context.Users.Where(n => n.UserName == "witek15").Select(n => n.Id).FirstOrDefault();
            m            = new Message();
            m.SenderID   = ids;
            m.ReceiverID = idr;
            m.Text       = "no cześć";
            m.Date       = new DateTime(2016, 11, 20, 10, 10, 15);
            m.Read       = true;
            context.Messages.AddOrUpdate(p => p.Date, m);
            context.SaveChanges();

            ids          = context.Users.Where(n => n.UserName == "witek15").Select(n => n.Id).FirstOrDefault();
            idr          = context.Users.Where(n => n.UserName == "jola17").Select(n => n.Id).FirstOrDefault();
            m            = new Message();
            m.SenderID   = ids;
            m.ReceiverID = idr;
            m.Text       = "idziemy na piwo?";
            m.Read       = true;
            m.Date       = new DateTime(2016, 11, 20, 10, 11, 5);
            context.Messages.AddOrUpdate(p => p.Date, m);
            context.SaveChanges();

            ids          = context.Users.Where(n => n.UserName == "jola17").Select(n => n.Id).FirstOrDefault();
            idr          = context.Users.Where(n => n.UserName == "witek15").Select(n => n.Id).FirstOrDefault();
            m            = new Message();
            m.SenderID   = ids;
            m.ReceiverID = idr;
            m.Text       = "za 15 minut na murkach";
            m.Read       = true;
            m.Date       = new DateTime(2016, 11, 20, 10, 11, 17);
            context.Messages.AddOrUpdate(p => p.Date, m);
            context.SaveChanges();


            ids          = context.Users.Where(n => n.UserName == "witek15").Select(n => n.Id).FirstOrDefault();
            idr          = context.Users.Where(n => n.UserName == "jola17").Select(n => n.Id).FirstOrDefault();
            m            = new Message();
            m.SenderID   = ids;
            m.ReceiverID = idr;
            m.Text       = "elo";
            m.Read       = true;
            m.Date       = new DateTime(2016, 11, 20, 10, 11, 29);
            context.Messages.AddOrUpdate(p => p.Date, m);
            context.SaveChanges();



            Category c = new Category();

            c.Name = "Motoring";
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            int fatherid = context.Categories.Where(p => p.Name == "Motoring").Select(p => p.CategoryID).First();

            c                  = new Category();
            c.Name             = "Cars";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            c                  = new Category();
            c.Name             = "Auto parts";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            c                  = new Category();
            c.Name             = "Car auto equipmnet";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();


            fatherid           = context.Categories.Where(p => p.Name == "Cars").Select(p => p.CategoryID).First();
            c                  = new Category();
            c.Name             = "Audi";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            c                  = new Category();
            c.Name             = "Fiat";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            c                  = new Category();
            c.Name             = "Mercedes";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();


            fatherid           = context.Categories.Where(p => p.Name == "Auto parts").Select(p => p.CategoryID).First();
            c                  = new Category();
            c.Name             = "Personal";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            c                  = new Category();
            c.Name             = "Vans and Trucks";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();


            c      = new Category();
            c.Name = "Music and Education";
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            fatherid           = context.Categories.Where(p => p.Name == "Music and Education").Select(p => p.CategoryID).First();
            c                  = new Category();
            c.Name             = "Books";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            c                  = new Category();
            c.Name             = "Music";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            fatherid           = context.Categories.Where(p => p.Name == "Books").Select(p => p.CategoryID).First();
            c                  = new Category();
            c.Name             = "Literature";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();

            c                  = new Category();
            c.Name             = "For children";
            c.CategoryFatherID = fatherid;
            context.Categories.AddOrUpdate(p => p.Name, c);
            context.SaveChanges();



            Models.Attribute a = new Models.Attribute();
            a.Name = "fuel";
            a.Type = "string";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Engine power";
            a.Type = "double";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Engine capacity";
            a.Type = "double";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Body type";
            a.Type = "string";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Transmission";
            a.Type = "string";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Country of origin";
            a.Type = "string";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Mileage";
            a.Type = "double";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Year";
            a.Type = "int";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Color";
            a.Type = "string";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Number of pages";
            a.Type = "int";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();

            a      = new Models.Attribute();
            a.Name = "Publication Year";
            a.Type = "int";
            context.Attributes.AddOrUpdate(p => p.Name, a);
            context.SaveChanges();



            int            aid = context.Attributes.Where(p => p.Name == "fuel").Select(p => p.AttributeID).First();
            AttributeValue av  = new AttributeValue();

            av.AttributeID = aid;
            av.Value       = "gasoline";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "diesel";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "LPG";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "CNG and hybrid";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();


            aid            = context.Attributes.Where(p => p.Name == "Body type").Select(p => p.AttributeID).First();
            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Cabriolet";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Sedan";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Coupe";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Pickup";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Hatchback";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Kombi";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "All-terrain";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Minibus";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Minivan";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "SUV";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();


            aid            = context.Attributes.Where(p => p.Name == "Transmission").Select(p => p.AttributeID).First();
            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Manual";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Automatic";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();


            aid            = context.Attributes.Where(p => p.Name == "Color").Select(p => p.AttributeID).First();
            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "White";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Black";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Gray";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Silver";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Blue";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Brown-Beige";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Red";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Green";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Yellow-Gold";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Different";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();


            aid            = context.Attributes.Where(p => p.Name == "Country of origin").Select(p => p.AttributeID).First();
            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Poland";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Germany";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Belarus";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Netherlands";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Sweden";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "USA";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "United Kingdom";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();

            av             = new AttributeValue();
            av.AttributeID = aid;
            av.Value       = "Different";
            context.AttributeValues.AddOrUpdate(p => p.Value, av);
            context.SaveChanges();



            int cid = context.Categories.Where(p => p.Name == "Cars").Select(p => p.CategoryID).First();

            aid = context.Attributes.Where(p => p.Name == "fuel").Select(p => p.AttributeID).First();
            CategoryAttribute ca = new CategoryAttribute();

            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Engine power").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Engine capacity").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Body type").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Transmission").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Country of origin").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Mileage").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Year").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            aid            = context.Attributes.Where(p => p.Name == "Color").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();


            cid            = context.Categories.Where(p => p.Name == "Books").Select(p => p.CategoryID).First();
            aid            = context.Attributes.Where(p => p.Name == "Number of pages").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();

            cid            = context.Categories.Where(p => p.Name == "Literature").Select(p => p.CategoryID).First();
            aid            = context.Attributes.Where(p => p.Name == "Publication Year").Select(p => p.AttributeID).First();
            ca             = new CategoryAttribute();
            ca.CategoryID  = cid;
            ca.AttributeID = aid;
            context.CategoryAttributes.AddOrUpdate(p => new { p.AttributeID, p.CategoryID }, ca);
            context.SaveChanges();



            Location l = new Location();

            l.LocationName = "Białystok";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Białystok, Dziesięciny";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Białystok, Centrum";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Białystok, Piasta";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Białystok, Bema";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Warszawa";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Warszawa, Mokotów";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Warszawa, Kabaty";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Warszawa, Młociny";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Warszawa, Stare Miasto";
            context.Locations.AddOrUpdate(p => p.LocationName, l);

            l = new Location();
            l.LocationName = "Warszawa, Śródmieście";
            context.Locations.AddOrUpdate(p => p.LocationName, l);


            string uid = context.Users.Where(p => p.UserName == "slightom").Select(p => p.Id).First();

            cid = context.Categories.Where(p => p.Name == "Audi").Select(p => p.CategoryID).First();
            Classified cl = new Classified();

            cl.UserID       = uid;
            cl.Name         = "Audi 80 2.0 benzyna";
            cl.Description  = "Mam do sprzedania elegancki samochód Audi 80 rocznik 95, silnik 2.0 w benzynie.";
            cl.CategoryID   = cid;
            cl.DateAdded    = new DateTime(2016, 12, 12, 13, 45, 00);
            cl.Counter      = 12;
            cl.Reported     = "";
            cl.Price        = 6500;
            cl.State        = "Used";
            cl.CategoryPath = "Motoring >> Cars >> Audi";
            context.Classifieds.AddOrUpdate(p => p.Name, cl);
            context.SaveChanges();

            int clid = context.Classifieds.Where(p => p.Name == "Audi 80 2.0 benzyna").Select(p => p.ClassifiedID).First();

            aid = context.Attributes.Where(p => p.Name == "fuel").Select(p => p.AttributeID).First();
            ClassifiedAttribute cla = new ClassifiedAttribute();

            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "gasoline";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Engine power").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "90";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Engine capacity").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "2000";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Body type").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "Kombi";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Transmission").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "Manual";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Country of origin").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "Poland";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Mileage").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "275000";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Year").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "1995";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Color").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "Different";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            int lid = context.Locations.Where(p => p.LocationName == "Białystok, Dziesięciny").Select(p => p.LocationID).First();
            ClassifiedLocation cll = new ClassifiedLocation();

            cll.ClassifiedID = clid;
            cll.LocationID   = lid;
            context.ClassifiedLocations.AddOrUpdate(p => new { p.LocationID, p.ClassifiedID }, cll);
            context.SaveChanges();



            PersonalizedCategory pc = new PersonalizedCategory();

            cid           = context.Categories.Where(p => p.Name == "Cars").Select(p => p.CategoryID).First();
            pc.UserID     = uid;
            pc.PriceMin   = 5000;
            pc.PriceMax   = 10000;
            pc.CategoryID = cid;
            pc.State      = "----";
            pc.Path       = "Motoring >> Cars";
            context.PersonalizedCategories.AddOrUpdate(p => new { p.UserID, p.CategoryID }, pc);
            context.SaveChanges();



            int pcid = context.PersonalizedCategories.Where(p => p.Category.Name == "Cars").Select(p => p.PersonalizedCategoryID).First();

            lid = context.Locations.Where(p => p.LocationName == "Białystok").Select(p => p.LocationID).First();
            PCL pcl = new PCL();

            pcl.PersonalizedCategoryID = pcid;
            pcl.LocationID             = lid;
            context.PCLs.AddOrUpdate(p => new { p.PersonalizedCategoryID, p.LocationID }, pcl);
            context.SaveChanges();



            Photo ph = new Photo();

            ph.ClassifiedID = clid;
            ph.MainPhoto    = true;
            ph.Path         = "/Content/photos/audi80_main.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();

            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = false;
            ph.Path         = "/Content/photos/audi80_1.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();

            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = false;
            ph.Path         = "/Content/photos/audi80_2.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();

            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = false;
            ph.Path         = "/Content/photos/audi80_3.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();



            ///////////////////////////////////////////////
            uid             = context.Users.Where(p => p.UserName == "witek15").Select(p => p.Id).First();
            cid             = context.Categories.Where(p => p.Name == "For Children").Select(p => p.CategoryID).First();
            cl              = new Classified();
            cl.UserID       = uid;
            cl.Name         = "Król Lew (idealny stan)";
            cl.Description  = "Mam do sprzedania cudowną książkę 'Król Lew'.";
            cl.CategoryID   = cid;
            cl.DateAdded    = new DateTime(2017, 01, 01, 13, 45, 00);
            cl.Counter      = 5;
            cl.Reported     = "";
            cl.Price        = 15;
            cl.State        = "Used";
            cl.CategoryPath = "Music and Education >> Books >> For children";
            context.Classifieds.AddOrUpdate(p => p.Name, cl);
            context.SaveChanges();



            clid             = context.Classifieds.Where(p => p.Name == "Król Lew (idealny stan)").Select(p => p.ClassifiedID).First();
            lid              = context.Locations.Where(p => p.LocationName == "Białystok, Centrum").Select(p => p.LocationID).First();
            cll              = new ClassifiedLocation();
            cll.ClassifiedID = clid;
            cll.LocationID   = lid;
            context.ClassifiedLocations.AddOrUpdate(p => new { p.LocationID, p.ClassifiedID }, cll);
            context.SaveChanges();



            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = true;
            ph.Path         = "/Content/photos/krolLew_main.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();

            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = false;
            ph.Path         = "/Content/photos/krolLew_1.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();


            clid             = context.Classifieds.Where(p => p.Name == "Król Lew (idealny stan)").Select(p => p.ClassifiedID).First();
            aid              = context.Attributes.Where(p => p.Name == "Number of pages").Select(p => p.AttributeID).First();
            cla              = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "120";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();



            ///////////////////////////////////////////////////////////////
            uid             = context.Users.Where(p => p.UserName == "witek15").Select(p => p.Id).First();
            cid             = context.Categories.Where(p => p.Name == "Books").Select(p => p.CategoryID).First();
            cl              = new Classified();
            cl.UserID       = uid;
            cl.Name         = "Dziennikarz śledczy";
            cl.Description  = "Mam do sprzedania bardzo ciekawą książkę 'Dziennikarz śledczy'. Bohaterem książki jest Cezary Gmyz.";
            cl.CategoryID   = cid;
            cl.DateAdded    = new DateTime(2017, 01, 02, 13, 45, 00);
            cl.Counter      = 9;
            cl.Reported     = "";
            cl.Price        = 30;
            cl.State        = "New";
            cl.CategoryPath = "Music and Education >> Books";
            context.Classifieds.AddOrUpdate(p => p.Name, cl);
            context.SaveChanges();



            clid             = context.Classifieds.Where(p => p.Name == "Dziennikarz śledczy").Select(p => p.ClassifiedID).First();
            lid              = context.Locations.Where(p => p.LocationName == "Białystok, Bema").Select(p => p.LocationID).First();
            cll              = new ClassifiedLocation();
            cll.ClassifiedID = clid;
            cll.LocationID   = lid;
            context.ClassifiedLocations.AddOrUpdate(p => new { p.LocationID, p.ClassifiedID }, cll);
            context.SaveChanges();



            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = true;
            ph.Path         = "/Content/photos/dziennikarzSledczy_main.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();



            clid             = context.Classifieds.Where(p => p.Name == "Dziennikarz śledczy").Select(p => p.ClassifiedID).First();
            aid              = context.Attributes.Where(p => p.Name == "Number of pages").Select(p => p.AttributeID).First();
            cla              = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "220";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();



            ///////////////////////////////////////////////////////////////
            uid             = context.Users.Where(p => p.UserName == "witek15").Select(p => p.Id).First();
            cid             = context.Categories.Where(p => p.Name == "Literature").Select(p => p.CategoryID).First();
            cl              = new Classified();
            cl.UserID       = uid;
            cl.Name         = "Call of the wild";
            cl.Description  = "Mam do sprzedania bardzo ciekawą książkę 'Zew Krwi'.";
            cl.CategoryID   = cid;
            cl.DateAdded    = new DateTime(2017, 01, 03, 13, 45, 00);
            cl.Counter      = 19;
            cl.Reported     = "";
            cl.Price        = 29.99;
            cl.State        = "New";
            cl.CategoryPath = "Music and Education >> Books >> Literature";
            context.Classifieds.AddOrUpdate(p => p.Name, cl);
            context.SaveChanges();



            clid             = context.Classifieds.Where(p => p.Name == "Call of the wild").Select(p => p.ClassifiedID).First();
            lid              = context.Locations.Where(p => p.LocationName == "Białystok, Bema").Select(p => p.LocationID).First();
            cll              = new ClassifiedLocation();
            cll.ClassifiedID = clid;
            cll.LocationID   = lid;
            context.ClassifiedLocations.AddOrUpdate(p => new { p.LocationID, p.ClassifiedID }, cll);
            context.SaveChanges();



            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = true;
            ph.Path         = "/Content/photos/callOfTheWild_main.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();



            clid             = context.Classifieds.Where(p => p.Name == "Call of the wild").Select(p => p.ClassifiedID).First();
            aid              = context.Attributes.Where(p => p.Name == "Number of pages").Select(p => p.AttributeID).First();
            cla              = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "184";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();

            aid = context.Attributes.Where(p => p.Name == "Publication Year").Select(p => p.AttributeID).First();
            cla = new ClassifiedAttribute();
            cla.ClassifiedID = clid;
            cla.AttributeID  = aid;
            cla.Value        = "2010";
            context.ClassifiedAttributes.AddOrUpdate(p => new { p.ClassifiedID, p.AttributeID }, cla);
            context.SaveChanges();



            ///////////////////////////////////////////////////////////////
            uid             = context.Users.Where(p => p.UserName == "jola17").Select(p => p.Id).First();
            cid             = context.Categories.Where(p => p.Name == "Music and Education").Select(p => p.CategoryID).First();
            cl              = new Classified();
            cl.UserID       = uid;
            cl.Name         = "CORT SFX-E NS Gitara elektroakustyczna";
            cl.Description  = "Mam do sprzedania bardzo ładnie brzmiącą gitarę firmy CORT";
            cl.CategoryID   = cid;
            cl.DateAdded    = new DateTime(2017, 01, 02, 12, 45, 00);
            cl.Counter      = 81;
            cl.Reported     = "";
            cl.Price        = 850.00;
            cl.State        = "Used";
            cl.CategoryPath = "Music and Education";
            context.Classifieds.AddOrUpdate(p => p.Name, cl);
            context.SaveChanges();



            clid             = context.Classifieds.Where(p => p.Name == "CORT SFX-E NS Gitara elektroakustyczna").Select(p => p.ClassifiedID).First();
            lid              = context.Locations.Where(p => p.LocationName == "Warszawa, Mokotów").Select(p => p.LocationID).First();
            cll              = new ClassifiedLocation();
            cll.ClassifiedID = clid;
            cll.LocationID   = lid;
            context.ClassifiedLocations.AddOrUpdate(p => new { p.LocationID, p.ClassifiedID }, cll);
            context.SaveChanges();



            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = true;
            ph.Path         = "/Content/photos/gitaracort_main.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();



            ///////////////////////////////////////////////////////////////
            uid             = context.Users.Where(p => p.UserName == "wiktor500").Select(p => p.Id).First();
            cid             = context.Categories.Where(p => p.Name == "Personal").Select(p => p.CategoryID).First();
            cl              = new Classified();
            cl.UserID       = uid;
            cl.Name         = "Drzwi lexus is 200 is 300";
            cl.Description  = "Drzwi lexus is 200 is 300. Możliwość wysyłki";
            cl.CategoryID   = cid;
            cl.DateAdded    = new DateTime(2017, 01, 07, 12, 45, 00);
            cl.Counter      = 21;
            cl.Reported     = "";
            cl.Price        = 120;
            cl.State        = "Used";
            cl.CategoryPath = "Motoring >> Auto parts >> Personal";
            context.Classifieds.AddOrUpdate(p => p.Name, cl);
            context.SaveChanges();



            clid             = context.Classifieds.Where(p => p.Name == "Drzwi lexus is 200 is 300").Select(p => p.ClassifiedID).First();
            lid              = context.Locations.Where(p => p.LocationName == "Warszawa, Mokotów").Select(p => p.LocationID).First();
            cll              = new ClassifiedLocation();
            cll.ClassifiedID = clid;
            cll.LocationID   = lid;
            context.ClassifiedLocations.AddOrUpdate(p => new { p.LocationID, p.ClassifiedID }, cll);
            context.SaveChanges();



            ph = new Photo();
            ph.ClassifiedID = clid;
            ph.MainPhoto    = true;
            ph.Path         = "/Content/photos/drzwi_main.jpg";
            context.Photos.AddOrUpdate(p => p.Path, ph);
            context.SaveChanges();
        }
Esempio n. 33
0
 public IActionResult EditClassified(Classified classified)
 {
     return(Ok(_classifiedsService.EditClassified(classified)));
 }
Esempio n. 34
0
        public void ClassifiedInfoUpdate(UUID queryClassifiedID, uint queryCategory, string queryName,
                                         string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
                                         byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
            {
                return; //Just fail
            }
            IScheduledMoneyModule scheduledMoneyModule = p.Scene.RequestModuleInterface <IScheduledMoneyModule> ();
            IMoneyModule          moneyModule          = p.Scene.RequestModuleInterface <IMoneyModule> ();
            Classified            classcheck           = ProfileFrontend.GetClassified(queryClassifiedID);

            if (((queryclassifiedFlags & 32) != 32) && moneyModule != null)
            {
                //Single week
                if (!moneyModule.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified", TransactionType.ClassifiedCharge))
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }
            else if (scheduledMoneyModule != null)
            {
                //Auto-renew
                if (classcheck != null)
                {
                    scheduledMoneyModule.RemoveFromScheduledCharge("[Classified: " + queryClassifiedID + "]");
                }

                var payOK = scheduledMoneyModule.Charge(
                    remoteClient.AgentId,                                                       // who to charge
                    queryclassifiedPrice,                                                       // how much
                    "Add Reoccurring Classified (" + queryClassifiedID + ")",                   // description
                    TransactionType.ClassifiedCharge,                                           // transaction type
                    "[Classified: " + queryClassifiedID + "]",                                  // scheduler identifier
                    true,                                                                       // charger immediately
                    false);                                                                     // run once
                if (!payOK)
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }

            UUID    creatorUUID     = remoteClient.AgentId;
            UUID    classifiedUUID  = queryClassifiedID;
            uint    category        = queryCategory;
            string  name            = queryName;
            string  description     = queryDescription;
            uint    parentestate    = queryParentEstate;
            UUID    snapshotUUID    = querySnapshotID;
            string  simname         = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos       = queryGlobalPos;
            byte    classifiedFlags = queryclassifiedFlags;
            int     classifiedPrice = queryclassifiedPrice;

            UUID   parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement = remoteClient.Scene.RequestModuleInterface <IParcelManagementModule> ();

            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.GlobalID;
                }
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified {
                ClassifiedUUID  = classifiedUUID,
                CreatorUUID     = creatorUUID,
                CreationDate    = creationdate,
                ExpirationDate  = expirationdate,
                Category        = category,
                Name            = name,
                Description     = description,
                ParcelUUID      = parceluuid,
                ParentEstate    = parentestate,
                SnapshotUUID    = snapshotUUID,
                SimName         = simname,
                GlobalPos       = globalpos,
                ParcelName      = parcelname,
                ClassifiedFlags = classifiedFlags,
                PriceForListing = classifiedPrice,
                ScopeID         = remoteClient.ScopeID
            };

            ProfileFrontend.AddClassified(classified);
        }
        public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName,
                                         string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
                                         byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
            {
                return; //Just fail
            }
            IMoneyModule money = p.Scene.RequestModuleInterface <IMoneyModule>();

            if (money != null)
            {
                Classified classcheck = ProfileFrontend.GetClassified(queryclassifiedID);
                if (classcheck == null)
                {
                    if (!money.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified"))
                    {
                        remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                        return;
                    }
                }
            }

            UUID    creatorUUID     = remoteClient.AgentId;
            UUID    classifiedUUID  = queryclassifiedID;
            uint    category        = queryCategory;
            string  name            = queryName;
            string  description     = queryDescription;
            uint    parentestate    = queryParentEstate;
            UUID    snapshotUUID    = querySnapshotID;
            string  simname         = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos       = queryGlobalPos;
            byte    classifiedFlags = queryclassifiedFlags;
            int     classifiedPrice = queryclassifiedPrice;

            UUID   parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement =
                remoteClient.Scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.InfoUUID;
                }
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified
            {
                ClassifiedUUID  = classifiedUUID,
                CreatorUUID     = creatorUUID,
                CreationDate    = creationdate,
                ExpirationDate  = expirationdate,
                Category        = category,
                Name            = name,
                Description     = description,
                ParcelUUID      = parceluuid,
                ParentEstate    = parentestate,
                SnapshotUUID    = snapshotUUID,
                SimName         = simname,
                GlobalPos       = globalpos,
                ParcelName      = parcelname,
                ClassifiedFlags = classifiedFlags,
                PriceForListing = classifiedPrice,
                ScopeID         = remoteClient.ScopeID
            };

            ProfileFrontend.AddClassified(classified);
        }
Esempio n. 36
0
        public ActionResult Create([Bind(Include = "ClassifiedID,UserID,Name,Description,CategoryID,DateAdded,Price,State,Counter,Reported")] Classified classified, AllAtributesModel aam, Location l, HttpPostedFileBase upload0, HttpPostedFileBase upload1, HttpPostedFileBase upload2, HttpPostedFileBase upload3)
        {
            if (ModelState.IsValid && classified.CategoryID != 0)
            {
                classified.DateAdded = DateTime.Now;
                classified.UserID    = User.Identity.GetUserId();

                ViewBag.badWord = consistBadWord(classified.Description);
                if (ViewBag.badWord != "")
                {
                    return(View("BadWord"));
                }

                string pom = db.Categories.Where(p => p.CategoryID == classified.CategoryID).Select(p => p.Name).First().ToString();
                classified.CategoryPath = categoryPath(pom);

                db.Classifieds.Add(classified);
                db.SaveChanges();

                #region adding classifiedLocation

                ClassifiedLocation cl = new ClassifiedLocation();
                cl.ClassifiedID = classified.ClassifiedID;
                string lid = db.Locations.Where(p => p.LocationName == l.LocationName).Select(p => p.LocationID).First().ToString();
                cl.LocationID = Int32.Parse(lid);
                db.ClassifiedLocations.Add(cl);
                db.SaveChanges();

                #endregion

                #region adding photos

                if (upload0 != null)
                {
                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;

                    //pelny sciezka do pliku
                    var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload0.jpg");
                    //zapis
                    upload0.SaveAs(path);

                    p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload0.jpg";
                    p.MainPhoto = true;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }
                else
                {
                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;

                    p.Path      = "/Content/photos/default.jpg";
                    p.MainPhoto = true;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }

                if (upload1 != null)
                {
                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;
                    //pelny sciezka do pliku
                    var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload1.jpg");
                    //zapis
                    upload1.SaveAs(path);

                    p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload1.jpg";
                    p.MainPhoto = false;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }

                if (upload2 != null)
                {
                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;

                    //pelny sciezka do pliku
                    var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload2.jpg");
                    //zapis
                    upload2.SaveAs(path);

                    p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload2.jpg";
                    p.MainPhoto = false;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }

                if (upload3 != null)
                {
                    Photo p = new Photo();
                    p.ClassifiedID = classified.ClassifiedID;

                    //pelny sciezka do pliku
                    var path = Path.Combine(Server.MapPath("~/Content/photos"), classified.ClassifiedID.ToString() + "_upload3.jpg");
                    //zapis
                    upload3.SaveAs(path);

                    p.Path      = "/Content/photos/" + classified.ClassifiedID.ToString() + "_upload3.jpg";
                    p.MainPhoto = false;

                    db.Photos.Add(p);
                    db.SaveChanges();
                }

                #endregion

                #region adding classifiedAttributes

                var list = giveMeSelectedAttributes(classified.CategoryID);
                foreach (string s in list)
                {
                    ClassifiedAttribute ca = new ClassifiedAttribute();
                    ca.ClassifiedID = classified.ClassifiedID;
                    string ss  = HomeController.whiteSpacesAgain(s);
                    string aid = db.Attributes.Where(p => p.Name == ss).Select(p => p.AttributeID).First().ToString();
                    ca.AttributeID = Int32.Parse(aid);
                    switch (s)
                    {
                    case "fuel": ca.Value = aam.fuel; break;

                    case "Engine_power": ca.Value = aam.Engine_power.ToString(); break;

                    case "Engine_capacity": ca.Value = aam.Enginie_capacity.ToString(); break;

                    case "Body_type": ca.Value = aam.Body_type; break;

                    case "Transmission": ca.Value = aam.Transmission; break;

                    case "Country_of_origin": ca.Value = aam.Country_of_origin; break;

                    case "Mileage": ca.Value = aam.Mileage.ToString(); break;

                    case "Year": ca.Value = aam.Year.ToString(); break;

                    case "Color": ca.Value = aam.Color; break;

                    case "Number_of_pages": ca.Value = aam.Number_of_pages.ToString(); break;

                    case "Publication_Year": ca.Value = aam.Publication_Year.ToString(); break;
                    }

                    db.ClassifiedAttributes.Add(ca);
                    db.SaveChanges();
                }



                #endregion



                return(RedirectToAction("Index"));
            }


            if (classified.CategoryID == 0)
            {
                ViewBag.Category0 = "You didn't choose Category!";
            }


            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Name", classified.CategoryID);
            ViewBag.UserID     = new SelectList(db.Users, "Id", "Email", classified.UserID);
            IEnumerable <SelectListItem> lss;
            List <SelectListItem>        ls = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = "New", Value = "1", Selected = true
                },
                new SelectListItem()
                {
                    Text = "Used", Value = "2"
                }
            };
            lss           = ls;
            ViewBag.State = new SelectList(lss, "Text", "Text");

            return(View(classified));
        }
        public int Insert(ClassifiedsView classifieds)
        {
            Classified classifiedsData = mapper.Map <Classified>(classifieds);

            return(database.Insert("classifieds", classifiedsData) == null ? 0 : 1);
        }