Esempio n. 1
0
        public IHttpActionResult ProfileGet()
        {
            Domain.Employer e;
            try
            {
                e = findEmployerBy();
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            if (e == null)
            {
                return(NotFound());
            }
            // Ensure link between email, onlineSigninID, and employer account are correct
            if (e.email != userEmail)
            {
                e.email = userEmail;
            }
            if (e.onlineSigninID == null)
            {
                e.onlineSigninID = userSubject;
                // aggressive linking of asp.net identity and employer record
                serv.Save(e, userEmail);
            }
            if (e.onlineSigninID != userSubject)
            {
                return(Conflict());
            }
            var result = map.Map <Domain.Employer, ViewModel.Employer>(e);

            return(Json(new { data = result }));
        }
Esempio n. 2
0
        public ActionResult ProfileGet()
        {
            Domain.Employer e;
            try
            {
                e = findEmployerBySubjectOrEmail();
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }

            if (e == null)
            {
                return(NotFound());
            }
            // Ensure link between email, onlineSigninID, and employer account are correct
            if (e.email != UserEmail)
            {
                e.email = UserEmail;
            }
            if (e.onlineSigninID == null)
            {
                e.onlineSigninID = UserSubject;
                // aggressive linking of asp.net identity and employer record
                serv.Save(e, UserEmail);
            }
            if (e.onlineSigninID != UserSubject)
            {
                return(Conflict());
            }
            var result = map.Map <Domain.Employer, EmployerViewModel>(e);

            return(new JsonResult(new { data = result }));
        }
        public async Task <ActionResult <DataPage <Vacancy> > > Index([FromQuery] VacancyFilter filter)
        {
            var result = await _vacancyService.GetFilteredAsync(filter);

            if (result.Objects.Any(w => w.Id == 0))
            {
                var vacancies = result.Objects.GroupBy(v => v.ExternalId).Select(vg => vg.FirstOrDefault()).ToList();

                var departments = vacancies.Where(v => v.Department != null).Select(v => v.Department).GroupBy(d => d.ExternalId).Select(dg => dg.FirstOrDefault()).ToList();
                foreach (var department in departments)
                {
                    _departmentService.Save(department);
                }

                var employers = vacancies.Where(v => v.Employer != null).Select(v => v.Employer).GroupBy(e => e.ExternalId).Select(eg => eg.FirstOrDefault()).ToList();
                foreach (var employer in employers)
                {
                    _employerService.Save(employer);
                }

                foreach (var vacancy in vacancies)
                {
                    _vacancyService.Save(vacancy);
                }
            }

            return(result);
        }
Esempio n. 4
0
 public JsonResult Edit(int id, FormCollection collection, string userName)
 {
     Domain.Employer employer = serv.Get(id);
     UpdateModel(employer);
     serv.Save(employer, userName);
     return(Json(new
     {
         jobSuccess = true
     }, JsonRequestBehavior.AllowGet));
 }
        public JsonResult Edit(int id, FormCollection collection, string userName)
        {
            Employer employer = serv.Get(id);

            UpdateModel(employer);
            serv.Save(employer, userName);
            return(Json(new
            {
                jobSuccess = true
            }));
        }
Esempio n. 6
0
        public async Task <JsonResult> Edit(int id, string userName)
        {
            ModelState.ThrowIfInvalid();

            var employer     = _serv.Get(id);
            var modelIsValid = await _adaptor.TryUpdateModelAsync(this, employer);

            if (modelIsValid)
            {
                _serv.Save(employer, userName);
                return(Json(new { jobSuccess = true }));
            }
            else
            {
                return(Json(new { jobSuccess = false }));
            }
        }