Exemplo n.º 1
0
        public IHttpActionResult PutMemberViewing(int id, MemberViewing memberViewing)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != memberViewing.MemberViewingID)
            {
                return(BadRequest());
            }

            db.Entry(memberViewing).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MemberViewingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
 void IEmployerViewsRepository.CreateMemberViewing(MemberViewing viewing)
 {
     using (var dc = CreateContext())
     {
         dc.MemberViewingEntities.InsertOnSubmit(viewing.Map());
         dc.SubmitChanges();
     }
 }
Exemplo n.º 3
0
        public IHttpActionResult GetMemberViewing(int id)
        {
            MemberViewing memberViewing = db.MemberViewings.Find(id);

            if (memberViewing == null)
            {
                return(NotFound());
            }

            return(Ok(memberViewing));
        }
Exemplo n.º 4
0
        public IHttpActionResult PostMemberViewing(MemberViewing memberViewing)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MemberViewings.Add(memberViewing);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = memberViewing.MemberViewingID }, memberViewing));
        }
Exemplo n.º 5
0
 public static MemberViewingEntity Map(this MemberViewing viewing)
 {
     return(new MemberViewingEntity
     {
         id = viewing.Id,
         time = viewing.Time,
         employerId = viewing.EmployerId,
         memberId = viewing.MemberId,
         jobAdId = viewing.JobAdId,
         channelId = viewing.ChannelId,
         appId = viewing.AppId,
     });
 }
Exemplo n.º 6
0
        public IHttpActionResult DeleteMemberViewing(int id)
        {
            MemberViewing memberViewing = db.MemberViewings.Find(id);

            if (memberViewing == null)
            {
                return(NotFound());
            }

            db.MemberViewings.Remove(memberViewing);
            db.SaveChanges();

            return(Ok(memberViewing));
        }
Exemplo n.º 7
0
        private void CreateMemberViewing(ChannelApp app, IHasId <Guid> employer, IHasId <Guid> member, Application application)
        {
            if (member == null)
            {
                return;
            }

            var viewing = new MemberViewing
            {
                EmployerId = employer == null ? (Guid?)null : employer.Id,
                MemberId   = member.Id,
                JobAdId    = application == null ? (Guid?)null : application.PositionId,
                ChannelId  = app.ChannelId,
                AppId      = app.Id,
            };

            viewing.Prepare();
            viewing.Validate();
            _repository.CreateMemberViewing(viewing);
        }