public IHttpActionResult Post(PostingCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            PostingService postingService = CreatePostingService();

            if (!postingService.CreatePosting(model))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Beispiel #2
0
        public bool CreatePosting(PostingCreate model)
        {
            var entity = new Posting()
            {
                OwnerId        = _userId,
                Title          = model.Title,
                IsUrgent       = model.IsUrgent,
                HiringManager  = model.HiringManger,
                Status         = model.Status,
                ExpirationDate = model.ExpirationDate,
                PositionType   = model.PositionType,
                CreatedBy      = model.CreatedBy,
                CreatedDate    = DateTime.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Postings.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public bool CreatePosting(PostingCreate model)
        {
            var entity = new Posting()
            {
                UserID         = _userID,
                Title          = model.Title,
                Details        = model.Details,
                Address        = model.Address,
                City           = model.City,
                State          = model.State,
                NameOfProvider = model.NameOfProvider,
                Category       = model.Category,
                DatePosted     = DateTime.Now,
                DateAvailable  = model.DateAvailable
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.PostingTable.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }