示例#1
0
        public async Task <ActionResult <CompanyAuthenticationProfileModel> > SignUp([FromBody] CompanySignUpModel companySignUpModel) => await Exec(async operation =>
        {
            if (User.Identity.IsAuthenticated)
            {
                throw new Exception(ExceptionMessage.UserHasAlreadyAuthenticated);
            }

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception(ExceptionMessage.CompanySignUpFailedDueToInvalidModel);
                }
                var profile = await userAuthenticationService.TrySignUp(operation, companySignUpModel.ToEntity());
                await LoginChallenge(profile, UserRole.Company);
                return(new CompanyAuthenticationProfileModel
                {
                    YandexMapsApiKey = configuration["Plugins:YandexMaps:ApiKey"],
                    DadataApiKey = configuration["Plugins:DaData:ApiKey"]
                }.ToModel(profile));
            }
            catch
            {
                await LogoutChallenge();
                throw;
            }
        });
示例#2
0
        public static CompanyDE Translate(this CompanySignUpModel from, CompanyDE dest = null)
        {
            var to = dest ?? new CompanyDE();

            if (to.Id <= 0)
            {
                to.Id       = from.Id;
                to.IsActive = true;
            }
            else
            {
                to.IsActive = from.IsActive;
                //to.ModifiedDate = DateTime.Now;
            }
            to.Name = from.CompanyName;
            ////to.Email = from.Email;
            ////to.Password = from.Password;
            ////to.ContactNo = from.Phone;
            //to.Logo = from.Logo;
            //to.CompanyName = from.CompanyName;
            //to.AddressId = from.AddressId;
            //to.UserImagePath = from.UserImagePath;
            //to.Biography = from.Biography;
            //to.CreatedById = from.CreatedById;
            //to.CreatedDate = from.CreatedDate;
            //to.IsActive = from.IsActive;

            return(to);
        }