Exemplo n.º 1
0
 public ActionResult StudioAdd(StudioAdminViewModel model)
 {
     if (ModelState.IsValid)
     {
         var api = GoPlayApi.Instance;
         var studio = new Studio()
         {
             name = model.name
         };
         studio.id = api.CreateStudio(studio);
         if (studio.id > 0)
         {
             var studioAssignment = new StudioAdminAssignment()
             {
                 studio_id = studio.id,
                 game_admin_id = CurrentUser.Id
             };
             api.CreateStudioAdminAssignment(studioAssignment);
             this.Flash(string.Format("Successfully added studio {0}!", model.name), FlashLevel.Success);
             return Redirect("/admin/studio/" + studio.id);
         }
         this.Flash(string.Format("Failure added studio {0}!", model.name), FlashLevel.Error);
     }
     return View(model);
 }
Exemplo n.º 2
0
 public ActionResult StudioAdd()
 {
     StudioAdminViewModel model = new StudioAdminViewModel()
     {
         action = "add"
     };
     return View(model);
 }
Exemplo n.º 3
0
 public ActionResult StudioEdit(int id)
 {
     var api = GoPlayApi.Instance;
     var studio = api.GetStudio(id).Data;
     if (studio == null)
     {
         this.Flash(string.Format("Studio with id {0} doesn't exist", id), FlashLevel.Warning);
         return Redirect("/admin/studio");
     }
     if (!PermissionHelper.HasManageStudio(CurrentUser.GetRoles(), CurrentUser.Id, id))
         return new HttpStatusCodeResult(403);
     StudioAdminViewModel model = new StudioAdminViewModel()
     {
         action = "edit",
         name = studio.name,
         studio_id = studio.id
     };
     model.previous_page = Request.Params["previous_page"];
     return View("StudioAdd", model);
 }
Exemplo n.º 4
0
        public ActionResult StudioEdit(StudioAdminViewModel model)
        {
            if (!ModelState.IsValid)
                return View("StudioAdd", model);

            var api = GoPlayApi.Instance;
            if (!PermissionHelper.HasManageStudio(CurrentUser.GetRoles(), CurrentUser.Id, model.studio_id.Value))
                return new HttpStatusCodeResult(403);

            var studio = new Studio()
            {
                id = model.studio_id.Value,
                name = model.name
            };
            if (api.UpdateStudio(studio))
            {
                this.Flash(string.Format("Successfully updated studio {0}!", model.name), FlashLevel.Success);
                return Redirect("/admin/studio/" + studio.id);
            }
            this.Flash(string.Format("Failure updated studio {0}!", model.name), FlashLevel.Error);
            return View("StudioAdd", model);
        }