// GET: CompanyProfile/Edit/5
        public async Task <ActionResult> Edit(Guid?id)
        {
            var company = _companyQueries.GetUiDto_CompanyFromUserGuid(User.Identity.GetUserId());

            // If there's a pending key to link the pro to the company, do it.
            var specialKey = new Helpers.Cookies().GetCookieAndDelete(this, Helpers.Cookies.CompanyLinkingKeyCookieName);

            if (!string.IsNullOrWhiteSpace(specialKey))
            {
                var success = await Task.Run(() => _linkingKeyQueries.UseLinkingKey_AddProfessionalToCompany(User.Identity.GetUserId(), specialKey));

                return(RedirectToAction("UseCompanyKeyComplete", "LK", new { isSuccess = success }));
            }

            // If they are not the owner, don't allow them to edit.
            if (company != null && !company.UILoadOnly_IsUserCompanyOwner)
            {
                return(RedirectToAction("Details", "CompanyProfile"));
            }

            // new company
            if (company == null)
            {
                var pro = _professionalQueries.GetUiDto_ProfessionalFromUserGuid(User.Identity.GetUserId());
                company = new AppointmentsDb.ModelsDto.CompanyUiDto();
                company.MainContactEmail = pro.EmailAddress;
                company.MainContactName  = pro.Honorific + " " + pro.Forename + " " + pro.Surname + " " + pro.Suffix;
            }

            return(View(company));
        }
예제 #2
0
        public async Task <ActionResult> Edit()
        {
            var professional = _professionalQueries.GetUiDto_ProfessionalFromUserGuid(User.Identity.GetUserId());

            if (professional == null)
            {
                // Create the professional. If there's a linking key, don't worry about it for now.
                professional = new ProfessionalUiDto();
                professional.ProfessionalId     = new Guid();
                professional.ProfessionalUserId = AppointmentsDb.Helpers.GuidHelper.GetGuid(User.Identity.GetUserId());
                professional.EmailAddress       = User.Identity.Name;
            }
            else
            {
                // If there's a pending key to link the pro to the company, do it.
                var specialKey = new Helpers.Cookies().GetCookieAndDelete(this, Helpers.Cookies.CompanyLinkingKeyCookieName);
                if (!string.IsNullOrWhiteSpace(specialKey))
                {
                    var success = await Task.Run(() => _linkingKeyQueries.UseLinkingKey_AddProfessionalToCompany(User.Identity.GetUserId(), specialKey));

                    return(RedirectToAction("UseCompanyKeyComplete", "LK", new { isSuccess = success }));
                }
            }

            return(View(professional));
        }
예제 #3
0
        public async Task <ActionResult> UseCompanyKeyConfirmed(string id)
        {
            Company company = null;

            if (User != null && User.Identity != null && User.Identity.GetUserId() != null)
            {
                company = await Task.Run(() => _companyQueries.GetCompanyAndThisEmployeeFromEmployeeProfessionalUserId(User.Identity.GetUserId()));
            }

            // If the professional does not exist, set a cookie for when they do and redirect them to set up!
            // Else, complete the process.
            // NOTE: When the Pro has linked at Professional or Company Stage of setup,
            //       they will be redirected back here to handle the setup.
            if (company == null)
            {
                // save something for connecting the pro after creation.
                new Helpers.Cookies().SetCookieValue(this, Helpers.Cookies.CompanyLinkingKeyCookieName, id, DateTime.Now.AddMinutes(20));

                return(RedirectToAction("Edit", "ProfessionalProfile"));
            }
            else
            {
                var success = await Task.Run(() => _linkingKeyQueries.UseLinkingKey_AddProfessionalToCompany(User.Identity.GetUserId(), id));

                return(RedirectToAction("UseCompanyKeyComplete", "LK", new { isSuccess = success }));
            }
        }