Exemplo n.º 1
0
        public async Task <IHttpActionResult> AddNewParty(PartyModel party)
        {
            if (party == null)
            {
                return(BadRequest("Please provide valid inputs!"));
            }

            if (string.IsNullOrEmpty(party.Location))
            {
                return(BadRequest("Please provide valid location!"));
            }

            if (await AuthService.ValidateUserAndToken(party.Token, party.UserID, party.Email, party.Location))
            {
                if (await PartyService.PartyExists(party))
                {
                    return(BadRequest("Party Already Exists"));
                }
                else
                {
                    if (await PartyService.AddNewParty(party))
                    {
                        return(Ok("Party Added Successfully!"));
                    }
                    else
                    {
                        return(BadRequest("Party Adding Failed!"));
                    }
                }
            }
            else
            {
                return(Unauthorized());
            }
        }