Exemplo n.º 1
0
        public async Task Add([FromBody] Models.Rsvp obj)
        {
            var bll_r = rsvpBusiness;

            var user = HttpContext.Items["EndUser"] as EF.EndUser;

            obj.MemberId = obj.MemberId == 0 ? user.MemberId : obj.MemberId;

            var r = await bll_r.Get(new EF.Rsvp {
                EventId = obj.EventId, MemberId = obj.MemberId
            });

            if (r == null)
            {
                await bll_r.Add(new EF.Rsvp {
                    EventId = obj.EventId, MemberId = obj.MemberId, IsGoing = obj.IsGoing
                });
            }
            else
            {
                await bll_r.Update(new EF.Rsvp {
                    EventId = obj.EventId, MemberId = obj.MemberId, IsGoing = obj.IsGoing
                });
            }
        }
Exemplo n.º 2
0
        public async Task Delete([FromBody] Models.Rsvp obj)
        {
            var bll_r = rsvpBusiness;

            var user = HttpContext.Items["EndUser"] as EF.EndUser;

            obj.MemberId = obj.MemberId == 0 ? user.Member.Id : obj.MemberId;

            await bll_r.Delete(new EF.Rsvp {
                EventId = obj.EventId, MemberId = obj.MemberId
            });
        }
 public void Create(Models.Rsvp rsvp)
 {
     using (var uow = _db.GetTransaction())
     {
         _db.Insert(rsvp);
         foreach (var response in rsvp.Responses)
         {
             _db.Insert(response);
         }
         _db.Execute(@"UPDATE core.Guests 
                         SET HasSentRsvp = 1 
                         WHERE Id IN (@0)",
                     rsvp.Responses.Select(x => x.GuestId));
         uow.Complete();
     }
 }
Exemplo n.º 4
0
        public async Task <IActionResult> Find([FromBody] Models.Rsvp obj)
        {
            var bll_r = rsvpBusiness;

            var user = HttpContext.Items["EndUser"] as EF.EndUser;

            obj.MemberId = obj.MemberId == 0 ? user.Member.Id : obj.MemberId;

            var res = from r in await bll_r.Find(obj.Member, obj.EventId, obj.IsGoing).ToListAsync()
                      select new
            {
                r.EventId,
                r.MemberId,
                Member = r.Member.Name,
                r.IsGoing,
                DateTimeResponded = r.DateModified
            };

            return(Json(res));
        }