Ejemplo n.º 1
0
        public HttpResponseMessage Donate(List <DonateItem> data)
        {
            HttpResponseMessage message = new HttpResponseMessage();
            long         userId         = SupportFilter.GetUserIdFromCookie();
            MyStatusCode state          = loverService.Donate(data, userId);

            message.StatusCode = (HttpStatusCode)state;
            return(message);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage UnfollowDog(long idDog)
        {
            long userId = SupportFilter.GetUserIdFromCookie();
            HttpResponseMessage message = new HttpResponseMessage();
            MyStatusCode        state   = dogService.UnfollowDog(userId, idDog);

            message.StatusCode = (HttpStatusCode)state;
            return(message);
        }
Ejemplo n.º 3
0
        public HttpResponseMessage SeeDonations()
        {
            HttpResponseMessage message = new HttpResponseMessage();
            long userId = SupportFilter.GetUserIdFromCookie();
            List <Dictionary <string, object> > donations = loverService.SeeDonations(userId);
            string content = LitJson.JsonMapper.ToJson(donations);

            message.Content    = new StringContent(content, System.Text.Encoding.UTF8, "application/json");
            message.StatusCode = HttpStatusCode.OK;
            return(message);
        }
Ejemplo n.º 4
0
        public HttpResponseMessage AdoptDog(dynamic data)
        {
            HttpResponseMessage         message = new HttpResponseMessage();
            Dictionary <String, Object> result  = new Dictionary <string, object>();
            long         idDog   = data.idDog;
            long         idLover = SupportFilter.GetUserIdFromCookie();
            MyStatusCode state   = dogService.AdoptDog(idLover, idDog);

            message.StatusCode = (HttpStatusCode)state;
            return(message);
        }
Ejemplo n.º 5
0
        public HttpResponseMessage SeeDogBasicInfo(long idDog)
        {
            long userId = SupportFilter.GetUserIdFromCookie();
            HttpResponseMessage         message = new HttpResponseMessage();
            Dictionary <string, object> dog     = dogService.SeeDogBasic(userId, idDog);
            string content = LitJson.JsonMapper.ToJson(dog);

            message.Content    = new StringContent(content, System.Text.Encoding.UTF8, "application/json");
            message.StatusCode = HttpStatusCode.OK;
            return(message);
        }
Ejemplo n.º 6
0
        public HttpResponseMessage GetAllAvailableDogs(int p)
        {
            long userId = SupportFilter.GetUserIdFromCookie();
            HttpResponseMessage message = new HttpResponseMessage();

            message.StatusCode = HttpStatusCode.Forbidden;
            if (p > 0)
            {
                List <Dictionary <String, Object> > dogs = dogService.GetAvailableDogs(userId, p);
                message.StatusCode = HttpStatusCode.OK;
                string content = LitJson.JsonMapper.ToJson(dogs);
                message.Content = new StringContent(content, System.Text.Encoding.UTF8, "application/json");
            }
            return(message);
        }
Ejemplo n.º 7
0
        public HttpResponseMessage CommentDog(dynamic data)
        {
            HttpResponseMessage message = new HttpResponseMessage();
            long    userId  = SupportFilter.GetUserIdFromCookie();
            Comment comment = new Comment()
            {
                idComment   = 0,
                commenter   = userId,
                content     = data.content,
                dog         = data.dog,
                commentTime = DateTime.Now
            };
            MyStatusCode state = loverService.CommentDog(comment);

            message.StatusCode = (HttpStatusCode)state;
            return(message);
        }
Ejemplo n.º 8
0
        public async System.Threading.Tasks.Task <HttpResponseMessage> SeeOwnInfo()
        {
            HttpResponseMessage message = new HttpResponseMessage();
            long userId = SupportFilter.GetUserIdFromCookie();

            if (!Request.Content.IsMimeMultipartContent())
            {
                message.StatusCode = HttpStatusCode.BadRequest;
                return(message);
            }

            string root     = HttpContext.Current.Server.MapPath("~/App_Data");
            var    provider = new MultipartFormDataStreamProvider(root);

            try
            {
                await Request.Content.ReadAsMultipartAsync(provider);

                DogLover lover = loverService.ProcessUpload(provider);
                lover.idUser = userId;
                if (lover.figure != null)
                {
                    message.StatusCode = loverService.Update(lover) ?
                                         HttpStatusCode.OK : (HttpStatusCode)MyStatusCode.Invalid;
                }
                else
                {
                    message.StatusCode = HttpStatusCode.InternalServerError;
                }
            }
            catch (Exception e)
            {
                message.StatusCode = HttpStatusCode.InternalServerError;
                return(message);
            }


            return(message);
        }