Пример #1
0
        public IHttpActionResult Put(WaitingParty party)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            using (var ctx = new WaitingPartyModel())
            {
                var existingParty = ctx.WaitingParties.Where(s => s.PartyId == party.PartyId)
                                    .FirstOrDefault <WaitingParty>();

                if (existingParty != null)
                {
                    existingParty.PriorityLvl = party.PriorityLvl;
                    ctx.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }

            return(Ok());
        }
Пример #2
0
        public IHttpActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Not a valid student id"));
            }

            using (var ctx = new WaitingPartyModel())
            {
                var party = ctx.WaitingParties
                            .Where(s => s.PartyId == id)
                            .FirstOrDefault();

                ctx.Entry(party).State = System.Data.Entity.EntityState.Deleted;
                ctx.SaveChanges();
            }

            return(Ok());
        }
Пример #3
0
 public IHttpActionResult Post(WaitingParty party)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Invalid data."));
     }
     using (var ctx = new WaitingPartyModel())
     {
         ctx.WaitingParties.Add(new WaitingParty()
         {
             PartyId      = party.PartyId,
             RestaurantID = party.RestaurantID,
             NoOfGuests   = party.NoOfGuests,
             AddTime      = party.AddTime,
             PriorityLvl  = party.PriorityLvl,
             FullName     = party.FullName,
             MobileUserId = party.MobileUserId
         });
         ctx.SaveChanges();
     }
     return(Ok());
 }