예제 #1
0
        public async Task <IActionResult> SubmitCreateOrEditScoialNetworkAsync(short id, short?siteSettingId, short?teamId, string name, string address, string faClass)
        {
            var socialNetwork = new SocialNetwork();

            if (id != 0)
            {
                socialNetwork = await _socialNetworkService.GetAll().FirstOrDefaultAsync(s => s.Id == id);

                socialNetwork.Name    = name;
                socialNetwork.Address = address;
                socialNetwork.FaClass = faClass;

                await _socialNetworkService.Update(socialNetwork);
            }
            else if (teamId != null)
            {
                socialNetwork.Name    = name;
                socialNetwork.Address = address;
                socialNetwork.FaClass = faClass;
                socialNetwork.TeamId  = teamId;

                await _socialNetworkService.Create(socialNetwork);
            }
            else
            {
                siteSettingId               = siteSettingId != null ? siteSettingId : _siteSettingService.GetAll().FirstOrDefault().Id;
                socialNetwork.Name          = name;
                socialNetwork.Address       = address;
                socialNetwork.FaClass       = faClass;
                socialNetwork.TeamId        = null;
                socialNetwork.SiteSettingId = siteSettingId;

                await _socialNetworkService.Create(socialNetwork);
            }
            return(ViewComponent("SocialNetwork", new { teamId = teamId }));
        }