Beispiel #1
0
        public IHttpActionResult AddFriends(int PackageId, Friends friendsToAdd)
        {
            if (PackageId < 1)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NoContent, "Sorry,package id Can not be smaller than 1")));
            }

            if (friendsToAdd == null)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NoContent, "Sorry, we could not get the data")));
            }

            Friends addedFriends;

            try
            {
                addedFriends = _packageManager.AddFriends(PackageId, friendsToAdd);
            }
            catch (Exception)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Something went wrong")));
            }

            if (addedFriends != null)
            {
                return(Ok(addedFriends));
            }
            else
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "We could not add friends, please try again")));
            }
        }