Пример #1
0
 public async Task<ActionResult> TeamQueueDashboard(Guid? id)
 {
     if (!Request.IsAjaxRequest())
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     var team = await AppDb.Team.FindAsync(id);
     if (id == null || team == null)
     {
         return Json(new { success = false, type = 1, message = "Error! User cannot be null." }, JsonRequestBehavior.AllowGet);
     }
     var model = new EditTeam
     {
         TeamId = team.TeamId,
         Name = team.Name,
         Alias = team.Alias,
         QueueId = team.QueueId,
         Enabled = team.Enabled,
         QueueDashboard = team.QueueDashboard
     };
     return (PartialView("_EditTeam", model));
 }
Пример #2
0
        public async Task<ActionResult> EditTeam(EditTeam model)
        {
            if (!Request.IsAjaxRequest())
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if (!ModelState.IsValid)
            {
                return Json(new { success = false, type = 1, message = "Error! Model state is not valid." }, JsonRequestBehavior.AllowGet);
            }
            var team = await AppDb.Team.FindAsync(model.TeamId);
            if (model.TeamId == null || team == null)
            {
                return Json(new { success = false, type = 1, message = "Error! Team not found." }, JsonRequestBehavior.AllowGet);
            }
            team.Name = model.Name;
            team.Alias = model.Alias;
            team.QueueId = model.QueueId;
            team.Enabled = model.Enabled;
            team.QueueDashboard = model.QueueDashboard;

            AppDb.Entry(team).State = EntityState.Modified;
            var result = await AppDb.SaveChangesAsync();
            {
                return Json(result > 0 ?
                    new { success = true, type = 3, message = "Team updated!" } :
                    new { success = false, type = 1, message = "Error! " }, JsonRequestBehavior.AllowGet);
            }
        }