public async Task UpdateTxtRecord(DnsDTO data)
 {
     using (var dns = new DnsAdmin())
     {
         await dns.SetTxtRecord(data.TxtRecord, data.DomainName);
     }
 }
示例#2
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));
        }