Example #1
0
        public string AddProfile(ProfileRegisterModel model, string userId)
        {
            try
            {
                var address = new Address()
                {
                    AddressLine1 = model.AddressLine1,
                    AddressLine2 = model.AddressLine2,
                    AddressMap   = model.AddressMap,
                    AreaCode     = model.AreaCode,
                    State        = model.State,
                    Suburb       = model.Suburb,
                };
                address.CreatedBy = address.ModifiedBy = userId;
                unitOfWork.AddressRepo.Insert(address);
                unitOfWork.Save();

                var tags = (from c in unitOfWork.TagRepo.Get(x => x.IsActive)
                            join d in model.Tags on c.Id equals d
                            select c).ToList();


                var result = new Profile()
                {
                    Id                    = userId,
                    Ethnicity             = model.Ethnicity,
                    AddressId             = address.Id,
                    CategoryId            = model.Category,
                    Experience            = model.Experince,
                    EyeColor              = model.EyeColor,
                    FacebookLink          = model.FacebookLink,
                    FluentLanguage        = model.FluentLanguages.Aggregate((x, y) => x + "," + y),
                    HairColor             = model.HairColor,
                    Height                = model.Height,
                    HipSize               = model.HipsSize,
                    Instagramlink         = model.InstagramLink,
                    IsWillingToTravel     = model.WillToTravel,
                    JacketSize            = model.JacketSize,
                    NationalityByBirth    = model.NationalityByBirth,
                    NationalityByPassport = model.NationalityByPassport,
                    PantSize              = model.PantSize,
                    ProfilePic            = model.ProfilePicsLocation,
                    ProfileUrl            = model.ProfilePicsLocation,
                    ShoeSize              = model.ShoeSize,
                    SpecialFeatures       = model.SpecialFeatures.Aggregate((x, y) => x + "," + y),
                    Status                = true,
                    Tags                  = tags,
                    TshirtSize            = model.TshirtSize,
                    WaistSise             = model.WaistSize,
                    DateOfBirth           = DateTime.ParseExact(model.Dob, "dd/MM/yyyy", new CultureInfo("en-US"), DateTimeStyles.None),
                };
                unitOfWork.ProfileRepo.Insert(result);
                unitOfWork.Save();
                return(result.Id);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult CreateProfile()
        {
            ProfileRegisterModel model = new ProfileRegisterModel();

            model.CategoryList.AddRange(_dropdownServices.GetCategories());
            model.ChestSizeList.AddRange(_dropdownServices.GetChestSize());
            model.EthnicityList.AddRange(_dropdownServices.GetEthnicities());
            model.ExperinceList.AddRange(_dropdownServices.GetExperiences());
            model.EyeColorList.AddRange(_dropdownServices.GetEyeColors());
            model.FluentLanguageList.AddRange(_dropdownServices.GetFluentLanguages());
            model.HairColorList.AddRange(_dropdownServices.GetHairColors());
            model.HeightList.AddRange(_dropdownServices.GetHeights());
            model.HipsSizeList.AddRange(_dropdownServices.GetHipSize());
            model.JacketSizeList.AddRange(_dropdownServices.GetJacketSize());
            model.NationalityBirthList.AddRange(_dropdownServices.GetNationalities());
            model.NationalityList.AddRange(_dropdownServices.GetNationalities());
            model.PantSizeList.AddRange(_dropdownServices.GetPantSize());
            model.ShoeSizeList.AddRange(_dropdownServices.GetShoeSize());
            model.SpecialFeatureList.AddRange(_dropdownServices.GetSpecialFeatures());
            model.TagList.AddRange(_dropdownServices.GetTags());
            model.TshirtSizeList.AddRange(_dropdownServices.GetTshirtSizes());
            model.WaistSizeList.AddRange(_dropdownServices.GetWaistSize());

            return(View(model));
        }
        public async Task <ActionResult> CreateProfile(ProfileRegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, PhoneNumber = model.MobileNumber
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    if (FileHelper.SaveProfileImage(model.ProfilePics, user.Id))
                    {
                        model.ProfilePicsLocation = FileHelper.ProfileImage(user.Id, model.ProfilePics.FileName);
                    }
                    var profileId = _profileServices.AddProfile(model, user.Id);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    if (string.IsNullOrWhiteSpace(profileId))
                    {
                        return(RedirectToAction("UpdateProfile", "Profile"));
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }
            model.CategoryList.AddRange(_dropdownServices.GetCategories());
            model.ChestSizeList.AddRange(_dropdownServices.GetChestSize());
            model.EthnicityList.AddRange(_dropdownServices.GetEthnicities());
            model.ExperinceList.AddRange(_dropdownServices.GetExperiences());
            model.EyeColorList.AddRange(_dropdownServices.GetEyeColors());
            model.FluentLanguageList.AddRange(_dropdownServices.GetFluentLanguages());
            model.HairColorList.AddRange(_dropdownServices.GetHairColors());
            model.HeightList.AddRange(_dropdownServices.GetHeights());
            model.HipsSizeList.AddRange(_dropdownServices.GetHipSize());
            model.JacketSizeList.AddRange(_dropdownServices.GetJacketSize());
            model.NationalityBirthList.AddRange(_dropdownServices.GetNationalities());
            model.NationalityList.AddRange(_dropdownServices.GetNationalities());
            model.PantSizeList.AddRange(_dropdownServices.GetPantSize());
            model.ShoeSizeList.AddRange(_dropdownServices.GetShoeSize());
            model.SpecialFeatureList.AddRange(_dropdownServices.GetSpecialFeatures());
            model.TagList.AddRange(_dropdownServices.GetTags());
            model.TshirtSizeList.AddRange(_dropdownServices.GetTshirtSizes());
            model.WaistSizeList.AddRange(_dropdownServices.GetWaistSize());
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult Add(ProfileRegisterModel profileRegistered)
        {
            var    title = "";
            string content;
            var    profile = Mapper.Map <ProfileRegisterModel, Profile>(profileRegistered);

            try
            {
                if (profileRegistered.UploadPhoto != null)
                {
                    WebImage img = new WebImage(profileRegistered.UploadPhoto.InputStream);
                    if (img.Width > 200 || img.Height > 200)
                    {
                        img.Resize(200, 200);
                    }

                    profile.Photo = img.GetBytes();
                }
            }
            catch (Exception)
            {
                title   = "Error!";
                content = "Formato de Imagen Incorrecto";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
                return(RedirectToAction("Add"));
            }
            var query =
                _profileRepository.Filter(e => e.FullName == profile.FullName);

            if (query.Any())
            {
                title   = "Error!";
                content = "El Perfil ya existe.";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
                return(RedirectToAction("Index"));
            }

            var profileCreated = _profileRepository.Create(profile);

            title   = "Perfil Agregado";
            content = profileCreated.FullName + "ha sido guardado exitosamente.";
            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
            return(RedirectToAction("Index"));
        }
Example #5
0
 public void SendProfile(ProfileRegisterModel profile)
 {
     Publish(RabbitMqConfig.RegisterProfileExchange, "register", Utils.ObjectConverter.ObjectToBytes(profile));
 }