public JsonResult <Response> AddProblem(int listId, int probId) { ProblemList pl = db.ProblemLists.First(p => p.Id == listId); if (pl == null) { return(Json(new Response { Status = HttpStatusCode.BadRequest, Message = "Invalid list ID" })); } if (pl.ProblemListEntries.Where(p => p.ProblemId == probId).Count() > 0) { return(Json(new Response { Status = HttpStatusCode.OK, Message = "Problem already on list" })); } ProblemListEntry ple = db.ProblemListEntries.Create(); ple.ProblemListId = listId; ple.ProblemId = probId; pl.ProblemListEntries.Add(ple); db.SaveChanges(); return(Json(new Response { Status = HttpStatusCode.OK, Message = "Added" })); }
private bool LoadPosition(PositionProxy p) { Position pos = Deproxy.GetPosition(p); string objTypeAndName = p.GetDataType().ToLower() + ": " + p.FriendlyString(); if (moonServer.Positions.Any(o => o.Id.Equals(pos.Id) || o.Name.Equals(pos.Name))) { if (ErrorOnDupCheckBox.Checked) { throw new DuplicateException(objTypeAndName); } StatusTextBox.AppendText("Skipping duplicate " + objTypeAndName + "\n"); return(false); } StatusTextBox.AppendText("Adding " + objTypeAndName + "\n"); moonServer.Positions.Add(pos); moonServer.SaveChanges(); return(true); }