public IActionResult leaveMessage(int id, [FromBody] messages newMessage) { if (HttpContext.Session.GetInt32("UserId") == null) { Dictionary <string, string> error = new Dictionary <string, string>(); error.Add("Message", "Error"); return(Json(error)); } int userId = HttpContext.Session.GetInt32("UserId") ?? default(int); if (ModelState.IsValid) { users addUser = dbContext.users.FirstOrDefault(u => u.userId == userId); channels channelAdd = dbContext.channels.Where(c => c.channelId == id).FirstOrDefault(); newMessage.channelId = id; newMessage.Channel = channelAdd; newMessage.userId = userId; newMessage.User = addUser; dbContext.messages.Add(newMessage); dbContext.SaveChanges(); Dictionary <string, string> success = new Dictionary <string, string>(); success.Add("Message", "Success"); return(Json(success)); } else { return(Json(ModelState)); } }
public IActionResult removeChannel(int id, int circleId) { if (HttpContext.Session.GetInt32("UserId") == null) { Dictionary <string, string> error = new Dictionary <string, string>(); error.Add("Message", "Error"); return(Json(error)); } int userId = HttpContext.Session.GetInt32("UserId") ?? default(int); if (dbContext.channels.Any(c => c.channelId == id)) { if (dbContext.circles.Any(c => c.circleId == circleId && c.userId == userId)) { channels userChan = dbContext.channels.Where(c => c.channelId == id).Include(u => u.messages).ThenInclude(m => m.likes).FirstOrDefault(); dbContext.channels.Remove(userChan); dbContext.SaveChanges(); Dictionary <string, string> success = new Dictionary <string, string>(); success.Add("Message", "Success"); return(Json(success)); } else { Dictionary <string, string> error = new Dictionary <string, string>(); error.Add("Message", "Error"); return(Json(error)); } } else { Dictionary <string, string> error = new Dictionary <string, string>(); error.Add("Message", "Error"); return(Json(error)); } }
public IActionResult createChannel(int id, [FromBody] channels newChannel) { if (HttpContext.Session.GetInt32("UserId") == null) { Dictionary <string, string> error = new Dictionary <string, string>(); error.Add("Message", "Error"); error.Add("hacking", "hacker"); return(Json(error)); } if (ModelState.IsValid) { circles circleAdd = dbContext.circles.Where(c => c.circleId == id).FirstOrDefault(); newChannel.circle = circleAdd; newChannel.circleId = id; dbContext.channels.Add(newChannel); dbContext.SaveChanges(); //========================================= //========================================= Dictionary <string, string> success = new Dictionary <string, string>(); success.Add("Message", "Success"); return(Json(success)); } else { return(Json(ModelState)); } }
public IActionResult GetChannel(int id) { channels retrievedChannel = dbContext.channels.FirstOrDefault(x => x.channelId == id); if (retrievedChannel.channelId == id) { return(Json(retrievedChannel)); } else { Dictionary <string, string> error = new Dictionary <string, string>(); error.Add("Message", "Error"); return(Json(error)); } }
output.Add(new Conv2D(channels, kernel_size, padding));
output.Add(new Conv2D(channels, kernel_size, strides, padding, use_bias: false));