Example #1
0
        async public Task <ActionResult> Create([Bind(Include = "Name")] GladiatorBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                var errorList = ModelState.Values.SelectMany(m => m.Errors)
                                .Select(e => e.ErrorMessage)
                                .ToList();

                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(errorList));
            }

            string userId = User.Identity.GetUserId();

            return(await GladiatorHandler.CreateGladiator(model, userId));
        }
Example #2
0
        async public Task <ActionResult> Edit([Bind(Include = "Id, Name, IsNPC")] GladiatorBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                var errorList = ModelState.Values.SelectMany(m => m.Errors)
                                .Select(e => e.ErrorMessage)
                                .ToList();

                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(errorList));
            }

            bool   isAdmin = User.IsInRole("Admin");
            string userId  = User.Identity.GetUserId();

            return(await GladiatorHandler.EditGladiator(model, userId, isAdmin));
        }