Esempio n. 1
0
        // GET: Team
        public async Task <ActionResult> Index()
        {
            TeamDTO team = null;

            if (User.IsInRole(CustomRoles.LabUserAssigned))
            {
                string labCode, teamCode;

                if (Session["labCode"] != null)
                {
                    labCode  = Session["labCode"].ToString();
                    teamCode = Session["teamCode"].ToString();
                }
                else
                {
                    return(RedirectToAction("SignIn", "Account", routeValues: new { force = "true" }));
                }

                team = await LabRepo.GetDomAssignment(labCode, teamCode);

                if (team == null || team.TeamAssignment == null)
                {
                    //something weird has happened with the team assignment when this user registered
                    //go re-register
                    ViewBag.ErrorMessage = "Your saved team information has been changed, or expired. Please re-associate your login with your team information.";
                    return(View("Register"));
                }
                var res = DnsDTO.FromTeamDTO(team);
                return(View(res));
            }

            return(View("Register"));
        }
 public async Task UpdateTxtRecord(DnsDTO data)
 {
     using (var dns = new DnsAdmin())
     {
         await dns.SetTxtRecord(data.TxtRecord, data.DomainName);
     }
 }
Esempio n. 3
0
        public async Task <ActionResult> UpdateAssignment(DnsDTO item)
        {
            string labCode  = Session["labCode"].ToString();
            string teamCode = Session["teamCode"].ToString();

            var data = await LabRepo.GetDomAssignment(labCode, teamCode);

            var test = ContinueEditingAssignment(data);

            if (test != null)
            {
                ViewBag.ErrorHeader = test.ErrorHeader;
                ViewBag.Error       = test.Error;
                ViewBag.IsLive      = true;
                return(View("Index"));
            }
            try
            {
                //updating DNS record
                using (var dns = new DnsAdmin())
                {
                    var domGroup = await _repo.GetGroup(data.Lab.AzureSubscriptionId, data.Lab.DnsZoneRG);

                    await dns.InitAsync();

                    dns.SetClient(domGroup);
                    await dns.SetTxtRecord(item.TxtRecord, data.TeamAssignment.DomainName);
                };
                //updating
                data.TeamAssignment.DnsTxtRecord = item.TxtRecord;
                await LabRepo.UpdateDnsRecord(data);
            }
            catch (Exception ex)
            {
                ViewBag.ErrorHeader = "DNS Update Failed";
                ViewBag.Error       = ex.Message;
                item.TxtRecord      = "";
            }
            item.DomainName = data.TeamAssignment.DomainName;
            item.LabId      = data.Lab.Id;
            return(View("Index", item));
        }