示例#1
0
        public async Task <IHttpActionResult> PostCompanyJob(string id, JobBindingModel job)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var userId = this.User.Identity.GetUserId();

            if (userId == null)
            {
                return(this.BadRequest("Invalid session token."));
            }

            var userCompany = await this.Data.Companies.All().FirstOrDefaultAsync(c => c.OwnerId == userId && c.Id == new Guid(id));

            if (userCompany == null)
            {
                return(BadRequest("You're not the owner of this company or the company does not exist"));
            }

            if (userCompany.Jobs.Any(j => j.Name == job.Name))
            {
                return(BadRequest("That job already exist for that company"));
            }

            this.Data.Jobs.Add(new Job()
            {
                Name    = job.Name,
                Company = userCompany
            });

            await this.Data.SaveChangesAsync();

            return(this.StatusCode(HttpStatusCode.Created));
        }
示例#2
0
        public ActionResult NewJob(Guid profileId, JobBindingModel form)
        {
            var profile = _uow.Profiles.FindById(profileId);
            profile.AddWorkExperience(form.Position, form.QuitReseason, form.Company, form.FromDate, form.ToDate);
            _uow.Save();

            return RedirectToAction<UserProfileController>(c => c.Index());
        }
示例#3
0
 public ActionResult NewJob(Guid profileId)
 {
     var vm = new JobBindingModel()
     {
         ProfileId = profileId,
         FromDate = DateTime.Today
     };
     return View(vm);
 }