Beispiel #1
0
        public ActionResult Create([Bind(Include = "Id,Name,Description")] Company company)
        {
            if (ModelState.IsValid)
            {
                db.Companies.Add(company);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(company));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "AppId,AppName")] App app)
        {
            if (ModelState.IsValid)
            {
                db.Apps.Add(app);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(app));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "JobId,Time,Day,Success,Files_DwUp,Files_Sorted,AppId")] Job job)
        {
            if (ModelState.IsValid)
            {
                db.Jobs.Add(job);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AppId = new SelectList(db.Apps, "AppId", "AppName", job.AppId);
            return(View(job));
        }
Beispiel #4
0
        private void SaveToDatabase()
        {
            string message;

            try
            {
                foreach (JobWrapper job in jobsList.Where(j => j.IsModified))
                {
                    if (db.Jobs.Any(j => j.Id == job.Id))
                    {
                        Job result = db.Jobs.SingleOrDefault(j => j.Id == job.Id);
                        result.JobDetails = job.JobDetails;
                        result.JobDate    = job.JobDate;
                    }
                    else
                    {
                        db.Jobs.Add(job.Job);
                    }
                }

                db.SaveChanges();
                message = "SaveSuccess";

                Messenger.Default.Send(new NotificationMessage(message));

                GetJobsAsync();
            }
            catch (SqlException ex) {
                SendError("SaveError", ex);
            }
        }
        public void DeleteJobById(int jobId)
        {
            using var db = new JobsContext();
            var jobToDelete = db.Jobs.Find(jobId);

            db.Jobs.Remove(jobToDelete);
            db.SaveChanges();
        }
Beispiel #6
0
        public bool AddJobs([FromForm] JobsVM model)
        {
            var category = db.Categories.FirstOrDefault(c => c.Name == model.Category) ?? new Category {
                Name = model.Category
            };
            var job = new Job
            {
                Category    = category,
                Deadline    = DateTime.Parse(model.Deadline),
                Priority    = model.Priority,
                Status      = (JobStatus)model.Status,
                Description = model.Description,
            };

            db.Jobs.Add(job);
            db.SaveChanges();
            return(true);
        }
Beispiel #7
0
        public Job add(Job job)
        {
            using (var db = new JobsContext())
            {
                db.Jobs.Add(job);
                db.SaveChanges();
            }

            return(job);
        }
Beispiel #8
0
        public Company add(Company company)
        {
            using (var db = new JobsContext())
            {
                db.Companies.Add(company);
                db.SaveChanges();
            }

            return(company);
        }
Beispiel #9
0
        private static void PopulateAddressTable()
        {
            using (TransactionScope transaction = new TransactionScope())

            {
                using (JobsContext db = new JobsContext())
                {
                    #region//person1
                    //TO-DO:  check whether person exists first...
                    ContactPerson person1 = new ContactPerson {
                        FirstName = "Ray", LastName = "Oflite"
                    };
                    db.People.Add(person1);
                    db.SaveChanges();

                    Address person1Addr = new Address {
                        Street = "8 Adams", City = "Detroit", StateProvince = "MI", PostalCode = "01237", ContactPersonId = person1.Id
                    };
                    db.Addresses.Add(person1Addr);
                    #endregion
                    ////////////////////////////////////////

                    #region//person 'Brice'
                    var     Brice           = db.People.Where(p => p.FirstName == "Brice").Single();
                    Address personBriceAddr = new Address {
                        Street = "8 Adams", City = "Detroit", StateProvince = "MI", PostalCode = "01237", ContactPersonId = Brice.Id
                    };
                    db.Addresses.Add(personBriceAddr);
                    #endregion

                    try
                    {
                        db.SaveChanges();
                        transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
        }
        //automapper?
        public Jobs UpdateJob(int jobIdToEdit, Jobs updateJobValues)
        {
            using var db = new JobsContext();
            var JobToEdit = db.Jobs.First(Jobs => Jobs.Id == jobIdToEdit);

            JobToEdit.Company     = updateJobValues.Company;
            JobToEdit.JobTitle    = updateJobValues.JobTitle;
            JobToEdit.Description = updateJobValues.Description;
            JobToEdit.Salary      = updateJobValues.Salary;
            JobToEdit.DateCreated = updateJobValues.DateCreated;
            db.SaveChanges();
            return(JobToEdit);
        }
Beispiel #11
0
 public List <WeatherForecast> WeatherForecasts()
 {
     using (var db = new JobsContext())
     {
         var rng = new Random();
         for (int i = 0; i < 10; i++)
         {
             db.WeatherForecasts.Add(new WeatherForecast
             {
                 DateFormatted = DateTime.Now.AddDays(i).ToString("d"),
                 TemperatureC  = rng.Next(-20, 55),
                 Summary       = Summaries[rng.Next(Summaries.Length)]
             });
         }
         db.SaveChanges();
         return(db.WeatherForecasts.ToList());
     }
 }
Beispiel #12
0
        public static void Initialize(JobsContext jobsApplied)
        {
            jobsApplied.Database.EnsureCreated();

            if (jobsApplied.JobsModel.Any())
            {
                return;
            }

            var jobs = new JobsModel
            {
                ID           = 1, company = "Amazon", title = "Software Engineer", job_number = "000001",
                last_checked = DateTime.Parse("2020-05-01"), last_updated = DateTime.Parse("2020-04-01"),
                date_applied = DateTime.Parse("2020-03-01"), status = "Active", notes = "Still Active",
                interview    = true, rejected = false, city = "Seattle", state = "Washington",
                country      = "United States"
            };

            jobsApplied.JobsModel.AddRange(jobs);
            jobsApplied.SaveChanges();
        }
 public void CreateCompany(Company newCompany)
 {
     using var db = new JobsContext();
     db.Add(newCompany);
     db.SaveChanges();
 }
 public void CreateJob(Jobs newJob)
 {
     using var db = new JobsContext();
     db.Add(newJob);
     db.SaveChanges();
 }