Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,ApplicationLink,Company,DatePosted,Experience,Hours,JobID,JobTitle,LanguagesUsed,Location,Salary")] JsonJob jsonJob)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jsonJob);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(jsonJob));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,Location,Name,PhoneNumber,Website")] CompanyID companyID)
        {
            if (ModelState.IsValid)
            {
                _context.Add(companyID);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(companyID));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ID,Company,DatePosted,Experience,Hours,JobTitle,Languages,Location,Salary,URL")] WebsiteID websiteID)
        {
            if (ModelState.IsValid)
            {
                _context.Add(websiteID);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(websiteID));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ID,Location")] PlaceID placeID)
        {
            if (ModelState.IsValid)
            {
                _context.Add(placeID);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(placeID));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("ID,Company,Contract,FullTime,JobTitle,Location,PartTime")] JobID jobID)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jobID);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(jobID));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> PostJobAsync([FromBody] PostJobRequest request)
        {
            var response = new SingleResponse <Job>();

            try
            {
                var existingEntity = await DbContext
                                     .GetJobsByJobTitleAsync(new Job { JobTitle = request.JobTitle });

                if (existingEntity != null)
                {
                    ModelState.AddModelError("JobTitle", "Job already exists");
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                // Create entity from request model
                var entity = request.ToEntity();

                // Add entity to repository
                DbContext.Add(entity);

                // Save entity in database
                await DbContext.SaveChangesAsync();

                // Set the entity to response model
                response.Model = entity;
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = "There was an internal error";

                Logger?.LogCritical("There was an error on '{0}' invocation: {1}", nameof(PostJobAsync), ex);
            }

            return(response.ToHttpCreatedResponse());
        }