public async Task <ActionResult> Edit(PreAuthDomain domain)
        {
            ViewBag.Templates = GetTemplates(domain.InviteTemplateId);
            ViewBag.Groups    = GetGroups(domain.Groups);

            if (ModelState.IsValid)
            {
                try
                {
                    domain.AuthUser = User.Identity.GetEmail();

                    if (domain.Id == null)
                    {
                        domain = await PreAuthDomain.AddDomain(domain);
                    }
                    else
                    {
                        domain = await PreAuthDomain.UpdateDomain(domain);
                    }

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    ViewBag.Operation = "Edit";
                    return(View(domain));
                }
            }
            return(View(domain));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create(PreAuthDomain domain)
        {
            ViewBag.Templates = GetTemplates(domain.InviteTemplateId);

            if (ModelState.IsValid)
            {
                try
                {
                    domain.AuthUser = User.Identity.GetEmail();
                    var doc = await PreAuthDomain.AddDomain(domain);

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View("Edit", domain));
                }
            }

            return(View("Edit", domain));
        }