Пример #1
0
        public ActionResult ProfilePut([FromBody] EmployerViewModel viewmodel)
        {
            bool newEmployer = false;
            var  employer    = findEmployerBySubjectOrEmail();

            if (employer == null)
            {
                employer    = new Domain.Employer();
                newEmployer = true;
            }
            employer.onlineSigninID = UserSubject;
            employer.email          = UserEmail;
            viewmodel.onlineSource  = true;
            map.Map <EmployerViewModel, Domain.Employer>(viewmodel, employer);

            Domain.Employer result;
            if (newEmployer)
            {
                result = serv.Create(employer, UserEmail);
            }
            else
            {
                serv.Save(employer, UserEmail);
                result = serv.Get(employer.ID);
            }
            var mapped = map.Map <Domain.Employer, EmployerViewModel>(result);

            return(new JsonResult(new { data = mapped }));
        }
Пример #2
0
        public ActionResult ProfilePost([FromBody] EmployerViewModel employer)
        {
            Domain.Employer e = null;
            e = findEmployerBySubjectOrEmail();
            // If
            if (e != null)
            {
                return(Conflict());
            }

            var domain = map.Map <EmployerViewModel, Domain.Employer>(employer);

            domain.onlineSigninID = UserSubject;
            if (UserEmail != null)
            {
                domain.email = UserEmail;
            }
            try
            {
                serv.Create(domain, UserEmail);
            }
            catch
            {
                return(StatusCode(500));
            }
            return(Ok());
        }
Пример #3
0
        public void Put(int id, [FromBody] EmployerViewModel employer)
        {
            var domain = serv.Get(employer.id);

            map.Map <EmployerViewModel, Domain.Employer>(employer, domain);
            serv.Save(domain, UserEmail);
        }
Пример #4
0
        public void Post([FromBody] EmployerViewModel employer)
        {
            var domain = map.Map <EmployerViewModel, Domain.Employer>(employer);

            serv.Create(domain, UserEmail);
        }