public async Task <IActionResult> PutCoverLetter([FromRoute] int id, [FromBody] CoverLetter coverLetter)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != coverLetter.CoverLetterID)
            {
                return(BadRequest());
            }

            _context.Entry(coverLetter).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CoverLetterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("ApplicationID,JobID,ApplicationSubmitted,ApplicationMethod")] Application application)
        {
            if (ModelState.IsValid)
            {
                _context.Add(application);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(application));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("PersonID,CompanyID,FirstName,LastName,Phone,Email,LinkedIn,Notes")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(person));
        }
        public async Task <IActionResult> Create([Bind("CoverLetterID,JobID,CoverLetterText")] CoverLetter coverLetter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(coverLetter);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(coverLetter));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Url,Notes,Active")] Company company)
        {
            if (ModelState.IsValid)
            {
                _context.Add(company);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(company));
        }
        public async Task <IActionResult> Create([Bind("CompanyName, CompanyID, CompanyUrl, JobOpeningTitle,JobOpeningRecorded,JobOpeningSource,JobOpeningUrl,JobOpeningDescription,JobOpeningNotes,JobOpeningActive")] AddJobOpeningViewModel jobOpening)
        {
            if (ModelState.IsValid)
            {
                HistoryItem tempHistoryItem;

                Company newCompany;
                if (jobOpening.CompanyName != "")
                {
                    //Create the company record
                    newCompany = new Company()
                    {
                        CompanyName   = jobOpening.CompanyName,
                        CompanyActive = true,
                        CompanyUrl    = jobOpening.CompanyUrl
                    };
                    _context.Add(newCompany);
                    await _context.SaveChangesAsync();

                    //Get the company ID
                    await _context.Entry(newCompany).GetDatabaseValuesAsync();

                    //Update the historyitem
                    tempHistoryItem = new HistoryItem()
                    {
                        HistoryItemCreated = DateTime.Now,
                        HistoryItemDate    = DateTime.Now,
                        HistoryItemEvent   = "Company Created",
                        CompanyID          = newCompany.CompanyID,
                        HistoryItemText    = newCompany.CompanyName + " was added."
                    };
                    _context.HistoryItems.Add(tempHistoryItem);
                    await _context.SaveChangesAsync();
                }
                else
                {
                    // Use the selected Company
                    newCompany = _context.Companies.SingleOrDefault(x => x.CompanyID == jobOpening.CompanyID);
                }

                //Create the job opening record
                var newJobOpening = new JobOpening()
                {
                    CompanyID             = newCompany.CompanyID,
                    JobOpeningTitle       = jobOpening.JobOpeningTitle,
                    JobOpeningDescription = jobOpening.JobOpeningDescription,
                    JobOpeningNotes       = jobOpening.JobOpeningNotes,
                    JobOpeningUrl         = jobOpening.JobOpeningUrl,
                    JobOpeningRecorded    = DateTime.Now,
                    JobOpeningSource      = jobOpening.JobOpeningSource,
                    JobOpeningActive      = true
                };
                _context.Add(newJobOpening);
                await _context.SaveChangesAsync();

                //Get the job ID
                await _context.Entry(newJobOpening).GetDatabaseValuesAsync();

                //Create historical item
                tempHistoryItem = new HistoryItem()
                {
                    HistoryItemCreated = DateTime.Now,
                    HistoryItemDate    = DateTime.Now,
                    HistoryItemEvent   = "Job Opening Created",
                    JobID           = newJobOpening.JobOpeningID,
                    HistoryItemText = ""
                };
                _context.HistoryItems.Add(tempHistoryItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(jobOpening));
        }