Exemplo n.º 1
0
        public void Update(Education update)
        {
            JobsEntities db = new JobsEntities();

            db.Educations.Add(update);
            db.SaveChanges();
        }
Exemplo n.º 2
0
        public void Add(JobCatalog add)
        {
            JobsEntities db = new JobsEntities();

            db.JobCatalogs.Add(add);
            db.SaveChanges();
        }
Exemplo n.º 3
0
        public void Add(CompanyInfo add)
        {
            JobsEntities db = new JobsEntities();

            db.CompanyInfoes.Add(add);
            db.SaveChanges();
        }
Exemplo n.º 4
0
        public void Add(InfoUser add)
        {
            JobsEntities db = new JobsEntities();

            db.InfoUsers.Add(add);
            db.SaveChanges();
        }
Exemplo n.º 5
0
        public void Add(Position add)
        {
            JobsEntities db = new JobsEntities();

            db.Positions.Add(add);
            db.SaveChanges();
        }
Exemplo n.º 6
0
        public void Add(City add)
        {
            JobsEntities db = new JobsEntities();

            db.Cities.Add(add);
            db.SaveChanges();
        }
Exemplo n.º 7
0
        public void Delete(JobCatalog add)
        {
            JobsEntities db = new JobsEntities();

            db.JobCatalogs.Attach(add);
            db.Entry(add).State = System.Data.Entity.EntityState.Deleted;
            db.SaveChanges();
        }
Exemplo n.º 8
0
        public void Edit(CompanyInfo add)
        {
            JobsEntities db = new JobsEntities();

            db.CompanyInfoes.Attach(add);
            db.Entry(add).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 9
0
        public void Edit(InfoUser add)
        {
            JobsEntities db = new JobsEntities();

            db.InfoUsers.Attach(add);
            db.Entry(add).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 10
0
        public void Delete(Position add)
        {
            JobsEntities db = new JobsEntities();

            db.Positions.Attach(add);
            db.Entry(add).State = System.Data.Entity.EntityState.Deleted;
            db.SaveChanges();
        }
    private static void CheckData(object sender)
    {
        MembershipUserCollection AllEmployer = Membership.GetAllUsers();

        foreach (MembershipUser Employer in AllEmployer)
        {
            //your condition to delete records (it can be everything you want date, specific data in config file)
            if (!Employer.IsApproved)
            {
                MeWork.Domain.Database.Employer FindedEmployer = JobDatabase.Employer.Find(Employer.ProviderUserKey);
                JobDatabase.Employer.Remove(FindedEmployer);
                JobDatabase.SaveChanges();
                Membership.DeleteUser(Employer.UserName, true);
            }
        }
    }
Exemplo n.º 12
0
        public void GetImagesByUrl(string url)
        {
            try
            {
                var imagesFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images");
                var randomFileName = Path.GetRandomFileName();
                var tempDirectory = Path.Combine(imagesFolder, randomFileName);

                Directory.CreateDirectory(tempDirectory);

                using (var client = new WebClient())
                {
                    var html = client.DownloadString(url);

                    var doc = new HtmlDocument();
                    doc.LoadHtml(html);

                    var imageNodes = doc.DocumentNode.SelectNodes("//img").Where(node => node.Name == "img").ToList();

                    foreach (var node in imageNodes)
                    {
                        if (node.Attributes.Contains("src"))
                        {
                            var src = node.Attributes["src"].Value;

                            if (!IsNullOrEmpty(src))
                            {
                                if (src.StartsWith("http"))
                                {
                                    var fileName = Guid.NewGuid() + Path.GetExtension(src);
                                    var outputFile = Path.Combine(tempDirectory, fileName);

                                    client.DownloadFile(src, outputFile);

                                    var size = new FileInfo(outputFile).Length;
                                    int width;
                                    int height;

                                    using (var stream = new FileStream(outputFile, FileMode.Open, FileAccess.Read))
                                    {
                                        var image = Image.FromStream(stream);
                                        width = image.Width;
                                        height = image.Height;
                                    }

                                    using (var context = new JobsEntities())
                                    {
                                        var imageInfo = new ImageInfo
                                        {
                                            ContentType = MimeMapping.GetMimeMapping(fileName),
                                            LocalUrl =
                                                ConfigurationManager.AppSettings["imagesUrl"] + randomFileName + "/" +
                                                fileName,
                                            RemoteUrl = src,
                                            JobId = Convert.ToInt32(JobContext.JobId),
                                            Size = size,
                                            Height = width,
                                            Width = height
                                        };

                                        context.ImageInfoes.Add(imageInfo);
                                        context.SaveChanges();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);

                throw;
            }
        }