Ejemplo n.º 1
0
        public IHttpActionResult PutExpressionLog(int id, ExpressionLog expressionLog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != expressionLog.ExpressionLogId)
            {
                return(BadRequest());
            }

            db.Entry(expressionLog).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExpressionLogExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetExpressionLog(int id)
        {
            ExpressionLog expressionLog = db.ExpressionLogs.Find(id);

            if (expressionLog == null)
            {
                return(NotFound());
            }

            return(Ok(expressionLog));
        }
Ejemplo n.º 3
0
        public IHttpActionResult PostExpressionLog(ExpressionLog expressionLog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ExpressionLogs.Add(expressionLog);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = expressionLog.ExpressionLogId }, expressionLog));
        }
Ejemplo n.º 4
0
        public IHttpActionResult DeleteExpressionLog(int id)
        {
            ExpressionLog expressionLog = db.ExpressionLogs.Find(id);

            if (expressionLog == null)
            {
                return(NotFound());
            }

            db.ExpressionLogs.Remove(expressionLog);
            db.SaveChanges();

            return(Ok(expressionLog));
        }
Ejemplo n.º 5
0
        public HttpResponseMessage PostSwipeAction(SwipeActionDTO swipeAction)
        {
            JinderDBEntities dbContext = new JinderDBEntities();
            var actionsTable           = dbContext.ExpressionLogs;
            var usersTable             = dbContext.JinderUsers;

            HttpResponseMessage message = new HttpResponseMessage();


            JinderUser sourcejinderuser = (from user in usersTable
                                           where user.JinderUserId == swipeAction.SourceUserId
                                           select user).FirstOrDefault <JinderUser>();

            JinderUser targetjinderuser = (from user in usersTable
                                           where user.JinderUserId == swipeAction.TargetUserId
                                           select user).FirstOrDefault <JinderUser>();

            if (swipeAction.SourceUserId == null || swipeAction.TargetUserId == null || swipeAction.IsInterested == null)
            {
                message.StatusCode = HttpStatusCode.BadRequest;
                return(message);
            }
            else
            if (sourcejinderuser == null || targetjinderuser == null)
            {
                message.StatusCode = HttpStatusCode.NotFound;
                return(message);
            }
            else
            {
                ExpressionLog action = new ExpressionLog();

                action.IsInterested = swipeAction.IsInterested;
                action.SourceUserId = swipeAction.SourceUserId;
                action.TargetUserId = swipeAction.TargetUserId;


                actionsTable.Add(action);
                dbContext.SaveChanges();

                message.StatusCode = HttpStatusCode.OK;

                return(message);
            }
        }