コード例 #1
0
        // GET: Guild/Create
        public ActionResult AddGuild(int?id)
        {
            var form = new GuildAddForm();
            var c    = m.CharacterGetById(id.GetValueOrDefault());

            form.LeaderId   = c.Id;
            form.LeaderName = c.Name;
            form.GameId     = c.Game.Id;
            form.GameName   = c.Game.Name;
            return(View(form));
        }
コード例 #2
0
        public ActionResult AddGuild(GuildAdd newItem)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var checkName = m.GuildgetByName(newItem.Name, newItem.GameId);
                    if (checkName == null)
                    {
                        var item = m.GuildAdd(newItem);
                        if (item != null)
                        {
                            return(RedirectToAction("Details", new { id = item.Id }));
                        }
                    }
                    else
                    {
                        var chara = m.CharacterGetById(newItem.LeaderId);
                        var f     = new GuildAddForm();
                        f.errorName  = "Name is already in use.";
                        f.LeaderName = chara.Name;
                        f.LeaderId   = chara.Id;
                        f.GameId     = chara.Game.Id;
                        f.GameName   = chara.Game.Name;
                        return(View(f));
                    }
                }
                catch (Exception e)
                {
                    return(HttpNotFound());
                }
            }
            var c    = m.CharacterGetById(newItem.LeaderId);
            var form = new GuildAddForm();

            form.LeaderName = c.Name;
            form.LeaderId   = c.Id;
            form.GameId     = c.Game.Id;
            form.GameName   = c.Game.Name;
            return(View(form));
        }