public async Task <bool> SubmitOffer(HelpOffer helpOffer)
 {
     try
     {
         if (helpOffer.Email == null)
         {
             helpOffer.Email = "no email";
         }
         if (helpOffer.Phone == null)
         {
             helpOffer.Phone = "no phone";
         }
         if (helpOffer.WebAddress == null)
         {
             helpOffer.WebAddress = "n/a";
         }
         _communityRepository.AddOffer(helpOffer);
         await _communityRepository.CommitAsync();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        public async Task <HttpStatusCode> AddHelpOffer(HelpOffer helpOffer)
        {
            _context.HelpOffers.Add(helpOffer);
            await _context.SaveChangesAsync();

            return(HttpStatusCode.Accepted);
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> AddHelpOffer(HelpOffer helpOffer)
        {
            if (!ModelState.IsValid)
            {
                return(Content((HttpStatusCode)202, "Invalid Model"));
            }

            var _help = await _user.AddHelpOffer(helpOffer);

            if (_help == HttpStatusCode.Accepted)
            {
                return(Content((HttpStatusCode)200, "Added Help offer successfully"));
            }
            return(Content((HttpStatusCode)201, "Help offer add failed"));
        }