Ejemplo n.º 1
0
        public IHttpActionResult Put(UpdatePosting posting)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreatePostingService();

            if (!service.UpdatePosting(posting))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Ejemplo n.º 2
0
        public bool UpdatePosting(UpdatePosting model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Postings
                    .Single(e => e.PostingID == model.PostingID && e.OwnerID == _userId);

                entity.Title             = model.Title;
                entity.ExpirationDateUtc = model.ExpirationDateUtc;
                entity.ModifiedDateUtc   = DateTimeOffset.UtcNow;
                entity.PostingStatus     = model.PostingStatus;
                entity.PositionType      = model.PositionType;
                entity.HiringManager     = model.HiringManager;
                entity.Urgent            = model.Urgent;

                return(ctx.SaveChanges() == 1);
            }
        }