Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("JobDutyId,JobType")] JobDuty jobDuty)
        {
            if (id != jobDuty.JobDutyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jobDuty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobDutyExists(jobDuty.JobDutyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobDuty));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Responsibilities,WorkExperienceID")] JobDuty jobDuty)
        {
            if (id != jobDuty.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jobDuty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobDutyExists(jobDuty.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["WorkExperienceID"] = new SelectList(_context.WorkExperience, "ID", "ID", jobDuty.WorkExperienceID);
            return(View(jobDuty));
        }
        public async Task <IActionResult> PutJobDuty([FromRoute] int id, [FromBody] JobDuty jobDuty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != jobDuty.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("JobDutyId,Duty,JobId")] JobDuty jobDuty)
        {
            if (id != jobDuty.JobDutyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jobDuty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobDutyExists(jobDuty.JobDutyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["JobId"] = new SelectList(_context.Job, "JobId", "JobId", jobDuty.JobId);
            return(View(jobDuty));
        }
Example #5
0
        public async Task <IActionResult> Create([Bind("JobDutyId,JobType")] JobDuty jobDuty)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jobDuty);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobDuty));
        }
        public async Task <IActionResult> PostJobDuty([FromBody] JobDuty jobDuty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.JobDuty.Add(jobDuty);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetJobDuty", new { id = jobDuty.Id }, jobDuty));
        }
        public async Task <IActionResult> Create([Bind("ID,Responsibilities,WorkExperienceID")] JobDuty jobDuty)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jobDuty);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["WorkExperienceID"] = new SelectList(_context.WorkExperience, "ID", "ID", jobDuty.WorkExperienceID);
            return(View(jobDuty));
        }
Example #8
0
        public async Task <IActionResult> Create([Bind("JobDutyId,Duty,JobId")] JobDuty jobDuty)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jobDuty);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["JobId"] = new SelectList(_context.Job, "JobId", "JobId", jobDuty.JobId);
            return(View(jobDuty));
        }
Example #9
0
        public JobDutyBase JobDutyAdd(JobDutyAdd newItem)
        {
            // Ensure that we can continue
            if (newItem == null)
            {
                return(null);
            }
            else
            {
                // Add the new object
                JobDuty addedItem = Mapper.Map <JobDuty>(newItem);

                ds.JobDuties.Add(addedItem);
                ds.SaveChanges();

                // Return the object
                return(Mapper.Map <JobDutyBase>(addedItem));
            }
        }
Example #10
0
    public HttpResponseMessage<JobDuty> AddJobDuty(JobDuty jobduty)
    {
        // Add the region that was passed in as the argument
            context.JobDuties.Add(jobduty);
            context.SaveChanges();

            // Prepare the response - we want to return "201 Created"
            HttpResponseMessage<JobDuty> response = new HttpResponseMessage<JobDuty>(jobduty, HttpStatusCode.Created);
            return response;
    }