public IHttpActionResult Post(CreatePosting posting) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePostingService(); if (!service.CreatePosting(posting)) { return(InternalServerError()); } return(Ok()); }
public bool CreatePosting(CreatePosting model) { var entity = new Posting() { OwnerID = _userId, Title = model.Title, CreatedDateUtc = DateTimeOffset.Now, ExpirationDateUtc = model.ExpirationDateUtc, PostingStatus = model.PostingStatus, PositionType = model.PositionType, HiringManager = model.HiringManager, Urgent = model.Urgent }; using (var ctx = new ApplicationDbContext()) { ctx.Postings.Add(entity); return(ctx.SaveChanges() == 1); } }