Beispiel #1
0
        public static OrgRegisterViewModel ToRegisterViewModel(Organization entity)
        {
            OrgRegisterViewModel model = new OrgRegisterViewModel();

            if (!string.IsNullOrEmpty(entity.LargePathImage))
            {
                model.LargePathImage = AppConstants.directoryProfileAvatar + entity.LargePathImage;
            }

            if (!string.IsNullOrEmpty(entity.SmallPathImage))
            {
                model.SmallPathImage = AppConstants.directoryProfileAvatar + entity.SmallPathImage;
            }

            model.Name               = entity.Name;
            model.ShortDescription   = entity.ShortDescription;
            model.Alias              = entity.Alias;
            model.IsActive           = entity.IsActive;
            model.ClassifierId       = entity.ClassifierId;
            model.DateCreate         = entity.DateCreate;
            model.DetailsDescription = entity.DetailsDescription;
            model.HeightImg          = entity.HeightImg;
            model.WidthImg           = entity.WidthImg;
            model.Id         = entity.Id;
            model.IsDelete   = entity.IsDelete;
            model.OwnerId    = entity.OwnerId;
            model.Classifier = entity.Classifier;
            model.Owner      = entity.Owner;
            model.Building   = entity.Building;
            model.Street     = entity.Street;
            model.Home       = entity.Home;
            model.Longitude  = entity.Longitude.ToString();
            model.Latitude   = entity.Latitude.ToString();
            return(model);
        }
Beispiel #2
0
        public static Organization ToEntity(OrgRegisterViewModel model)
        {
            Organization entity = new Organization();

            entity.LargePathImage     = model.LargePathImage;
            entity.SmallPathImage     = model.SmallPathImage;
            entity.Name               = model.Name;
            entity.ShortDescription   = model.ShortDescription;
            entity.Alias              = model.Alias;
            entity.IsActive           = model.IsActive;
            entity.ClassifierId       = model.ClassifierId;
            entity.DateCreate         = model.DateCreate;
            entity.DetailsDescription = model.DetailsDescription;
            entity.HeightImg          = model.HeightImg;
            entity.WidthImg           = model.WidthImg;
            entity.Id        = model.Id;
            entity.IsDelete  = model.IsDelete;
            entity.OwnerId   = model.OwnerId;
            entity.Building  = model.Building;
            entity.Street    = model.Street;
            entity.Home      = model.Home;
            entity.Longitude = decimal.Parse(model.Longitude, CultureInfo.InvariantCulture.NumberFormat);
            entity.Latitude  = decimal.Parse(model.Latitude, CultureInfo.InvariantCulture.NumberFormat);
            entity.Notation  = model.Notation;

            return(entity);
        }
        public ActionResult Company(OrgRegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();

                ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
                return(View(model));
            }

            AppUser user = new AppUser
            {
                UserName          = model.Email,
                Email             = model.Email,
                LockoutEnabled    = true,
                LockoutEndDateUtc = DateTime.Now.AddHours(7)
            };



            IdentityResult identResult = UserManager.Create(user, model.Password);

            if (!identResult.Succeeded)
            {
                AddErrorsFromResult(identResult);
                ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
                return(View(model));
            }
            model.SmallPathImage = ImageResize.Resize(model.LogoFile, AppConstants.directoryProfileAvatar, 40, 40);
            model.LargePathImage = ImageResize.Resize(model.LogoFile, AppConstants.directoryProfileAvatar, 135, 135);
            model.OwnerId        = user.Id;
            UserManager.AddToRole(user.Id, RoleConstant.RoleCompany);
            orgService.Edit(OrganizationMapper.ToEntity(model));
            profileService.Edit(UserProfileMapper.ToEntity(model));



#if _DEBUG
            SignInManager.SignIn(user, model.RememberMe, false);
            return(Redirect("~/"));
#endif

#if _RELEASE
            string token = UserManager.GenerateEmailConfirmationToken(user.Id);
            SendEmail(new EmailVerify
            {
                CallbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, token = token }),
                cid         = Guid.NewGuid().ToString(),
                UserName    = user.UserName
            }, user.Id);

            return(View("TwoFactorMessage"));
#endif
        }
Beispiel #4
0
 public static UserProfile ToEntity(OrgRegisterViewModel model)
 {
     return(new UserProfile
     {
         GivenName = model.Email,
         PicturePath = model.SmallPathImage,
         UserId = model.OwnerId,
         IsActive = true,
     });
 }