public IEnumerable <string> Post([FromBody] MobileConnector visitor) { if (_dbContext != null) { _dbContext.Visitors.Add(visitor); _dbContext.SaveChanges(); } return(new string[] { _htmlEncoder.Encode("Hello " + visitor.Name) }); }
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()); } }
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)); } }
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)); } }