コード例 #1
0
        public IEnumerable <string> Post([FromBody] MobileConnector visitor)
        {
            if (_dbContext != null)
            {
                _dbContext.Visitors.Add(visitor);
                _dbContext.SaveChanges();
            }

            return(new string[] { _htmlEncoder.Encode("Hello " + visitor.Name) });
        }
コード例 #2
0
 public IEnumerable <string> Post([FromBody] Visitor visitor)
 {
     if (_dbContext == null)
     {
         return(new string[] { _htmlEncoder.Encode(visitor.Name) });
     }
     else
     {
         _dbContext.Visitors.Add(visitor);
         _dbContext.SaveChanges();
         return(_dbContext.Visitors.Select(m => _htmlEncoder.Encode(m.Name)).ToList());
     }
 }
コード例 #3
0
 public ActionResult CreateUser()
 {
     if (_dbContext == null)
     {
         return(Json("No database"));
     }
     else
     {
         User u = new User("John");
         _dbContext.Users.Add(u);
         _dbContext.SaveChanges();
         return(Json(u));
     }
 }
コード例 #4
0
 public ActionResult CreateTask([FromBody] TaskMinimal taskMin, int creatorId)
 {
     if (_dbContext == null)
     {
         return(Json("No database"));
     }
     else
     {
         User        creator  = _dbContext.Users.Find(creatorId);
         User        accepter = null;
         Models.Task task     = new Models.Task(taskMin.Description, taskMin.Image, taskMin.Score, taskMin.Lattitude, taskMin.Longtitude, creator, accepter);
         _dbContext.Tasks.Add(task);
         _dbContext.SaveChanges();
         return(Json(task));
     }
 }