示例#1
0
文件: PartySvc.cs 项目: BeVC/FoodList
        public PartyResult CreateNewParty(party newParty)
        {
            try
            {
                if (newParty == null)
                    return new PartyResult(PartyStatus.NoPartyPresent);

                party party = new party
                {
                    id = Guid.NewGuid().ToString(),
                    firstName = newParty.firstName,
                    lastName = newParty.lastName,
                    name = newParty.name,
                    pantryId = Guid.NewGuid().ToString()
                };

                _db.party.Add(party);
                _db.SaveChanges();

                return new PartyResult(party);

            }
            catch (Exception ex)
            {
                return new PartyResult(PartyStatus.Error);
            }
        }
示例#2
0
        public HttpResponseMessage Put(party newParty)
        {
            PartySvc svc = new PartySvc();

            var result = svc.CreateNewParty(newParty);

            return Request.CreateResponse(HttpStatusCode.OK, result);
        }
示例#3
0
文件: PartySvc.cs 项目: BeVC/FoodList
 public PartyResult(party party)
 {
     Party = party;
     Status = PartyStatus.Ok;
     StatusMessage = Status.ToString();
 }