public IHttpActionResult Login(loginViewModel model)
        {
            var getuser = new AspNetUserRepository().FirstOrDefault(x => x.UserName == model.UserName || x.PhoneNumber == model.mobileNumber || x.Email == model.Email);

            if (getuser != null)
            {
                var user = UserManager.Find(getuser.UserName, model.password);

                if (user != null)
                {
                    var data = new loginViewModel();
                    data.user_id = user.Id;

                    return(Json(new { data, message = "Login Successfully.", success = "true" }));
                }
                else
                {
                    return(Json(new { data = "null", message = "Email / Password is incorrect.", success = "false" }));
                    // return Ok("Not Exist");
                }
            }
            else
            {
                return(Json(new { data = "null", message = "Email / Password is incorrect.", success = "false" }));
            }
        }
 public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     
     using (DALDbContext db = new DALDbContext())
     {
         AspNetUserRepository iUser = new AspNetUserRepository(db);
         //AspNetUser user = iUser
         
     }
     
     // This doesn't count login failures towards account lockout
     // To enable password failures to trigger account lockout, change to shouldLockout: true
     var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: true);
     switch (result)
     {
         case SignInStatus.Success:
             return RedirectToLocal(returnUrl);
         case SignInStatus.LockedOut:
             return View("Lockout");
         case SignInStatus.RequiresVerification:
             return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
         case SignInStatus.Failure:
         default:
             ModelState.AddModelError("", "Invalid login attempt.");
             return View(model);
     }
 }
示例#3
0
 public CampaignManager()
 {
     telemetria                = new Trace();
     repository                = new CampaignRepository();
     userRepository            = new AspNetUserRepository();
     transactionCaptRepository = new TransactionCaptRepository();
     productRepository         = new ProductRepository();
 }
 public AspNetUser GetByUserName(string username)
 {
     using (AspNetUserRepository repository = new AspNetUserRepository())
     {
         repository.ProxyCreationEnabled = false;
         return(repository.GetSingle(u => u.UserName == username));
     }
 }
 public virtual Task <AspNetUser> GetSingleAsync(Func <AspNetUser, bool> where,
                                                 params Expression <Func <AspNetUser, object> >[] navigationProperties)
 {
     using (AspNetUserRepository repository = new AspNetUserRepository())
     {
         repository.ProxyCreationEnabled = false;
         return(repository.GetSingleAsync(where, navigationProperties));
     }
 }
示例#6
0
 public Task DeleteAsync(AspNetUser user)
 {
     return(Task.Factory.StartNew(() =>
     {
         using (AspNetUserRepository repository = new AspNetUserRepository())
         {
             repository.Remove(user);
         }
     }));
 }
示例#7
0
 public Task <AspNetUser> FindByIdAsync(int userId)
 {
     return(Task <AspNetUser> .Factory.StartNew(() =>
     {
         using (AspNetUserRepository repository = new AspNetUserRepository())
         {
             var result = repository.GetSingle(user => user.Id == userId);
             return result;
         }
     }));
 }
示例#8
0
        public UnitOfWork(ApplicationEntities context)
        {
            _context = context;

            Users           = new AspNetUserRepository(_context);
            Roles           = new AspNetRoleRepository(_context);
            Companies       = new CompanyRepository(_context);
            Beacons         = new BeaconRepository(_context);
            SurveyAnswers   = new SurveyAnswerRepository(_context);
            SurveyQuestions = new SurveyQuestionRepository(_context);
        }
示例#9
0
 public Task <AspNetUser> FindByNameAsync(string userName)
 {
     return(Task <AspNetUser> .Factory.StartNew(() =>
     {
         using (AspNetUserRepository repository = new AspNetUserRepository())
         {
             var result = repository.GetSingle(user => user.UserName == userName);
             return result;
         }
     }));
 }
示例#10
0
 public Task UpdateAsync(AspNetUser user)
 {
     return(Task.Factory.StartNew(() =>
     {
         using (AspNetUserRepository repository = new AspNetUserRepository())
         {
             user.Updated = DateTime.Now;
             //user.Password = GetPassword(user);
             repository.Update(new AspNetUser[] { user });
         }
     }));
 }
示例#11
0
 public Task CreateAsync(AspNetUser user)
 {
     return(Task.Factory.StartNew(() =>
     {
         using (AspNetUserRepository repository = new AspNetUserRepository())
         {
             user.Updated = DateTime.Now;
             user.Password = PasswordHasher.HashPassword(user.Password);
             repository.Add(user);
         }
     }));
 }
示例#12
0
        public string getAspNetUserIdByName(string name)
        {
            AspNetUser user = AspNetUserRepository.Get(filter: m => m.UserName == name).FirstOrDefault();

            if (user != null)
            {
                return(user.Id);
            }
            else
            {
                return(null);
            }
        }
示例#13
0
 public Task <AspNetUser> FindAsync(string userName, string password)
 {
     return(Task <AspNetUser> .Factory.StartNew(() =>
     {
         using (AspNetUserRepository repository = new AspNetUserRepository())
         {
             //repository.LazyLoadingEnabled = false;
             repository.ProxyCreationEnabled = false;
             password = PasswordHasher.HashPassword(password);
             var result = repository.GetSingle(user => user.UserName == userName && user.Password == password, user => user.AspNetUserClaim, user => user.AspNetUserClaim);
             //return result;
             return (AspNetUser)DeepCopy.CloneInternal(result, 2);
         }
     }));
 }
示例#14
0
 public AspNetUserManager()
 {
     repository = new AspNetUserRepository();
 }
示例#15
0
        public bool SaveProduct(Models.Publisher.CreateProductModel _createModel, string UserIdentity, Models.Core.FileUpload fileUpload)
        {
            //Creamos los repositorios
            SiteRepository        siteRepository        = new SiteRepository();
            AspNetUserRepository  aspNetUserRepository  = new AspNetUserRepository();
            ProductTypeRepository productTypeRepository = new ProductTypeRepository();
            PartnerRepository     partnerRepository     = new PartnerRepository();
            ProductRepository     productRepository     = new ProductRepository();

            //Obtenemos los conjuntos
            List <SiteEntity>        sites        = siteRepository.GetAll().ToList();
            List <AspNetUserEntity>  users        = aspNetUserRepository.GetAll().ToList();
            List <ProductTypeEntity> productstype = productTypeRepository.GetAll().ToList();
            List <PartnerEntity>     partners     = partnerRepository.GetAll().ToList();

            //Obtenemos las entidades deseadas.
            SiteEntity site = (from s in sites
                               where s.IdSite == _createModel.SiteTypeSelecc
                               select s).FirstOrDefault();
            AspNetUserEntity user = (from u in users
                                     where u.Id == UserIdentity
                                     select u).FirstOrDefault();

            ProductTypeEntity productType = (from pr in productstype
                                             where pr.IdProductType == _createModel.ProductTypeSelect
                                             select pr).FirstOrDefault();
            PartnerEntity partner = (from p in partners
                                     where p.IdPartner == _createModel.ParterTypeSelect
                                     select p).FirstOrDefault();

            ProductEntity product = new ProductEntity
            {
                //AspNetUser = user,
                AspNetUsers_Id             = UserIdentity,
                IdProduct                  = Guid.NewGuid(),
                Price                      = _createModel.PriceSelecc,
                ShortDescription           = _createModel.Name,
                FullDescription            = string.Empty,
                StartTime                  = Helpers.DateTimeHelper.GetCurrentDateString(),
                EndTime                    = Helpers.DateTimeHelper.GetCurrentDateString(0, 30),
                RegistrationDate           = DateTime.Now,
                SITE_IdSite                = site.IdSite,
                PRODUCT_TYPE_IdProductType = productType.IdProductType,
                PARTNER_IdPartner          = partner.IdPartner,
                Image                      = string.Empty,
                IsActive                   = true,
                IsPremium                  = _createModel.IsPremium
            };

            if (fileUpload != null)
            {
                product.Image = Helpers.AzureStorageHelper.CreateBlobImageFile(fileUpload.FileData, fileUpload.Filextension);
            }
            else
            {
                product.Image = Helpers.AzureStorageHelper.CreateBlobImageFile(getImageFromUrl(""), ".png");
            }


            productRepository.Add(product);

            if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_SUBSCRIBERS)) ||
                _createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_PUSH_CREW)) ||
                _createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_PUSH_ENGAGE)))
            {
                AddProductSettingEntity(product, "pushApiToken", _createModel.Token);
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_MAIL_CHIMP)))
            {
                AddProductSettingEntity(product, "mailChimpApiToken", _createModel.Token);
                AddProductSettingEntity(product, "mailChimpList", _createModel.ListMCSelecc);
                AddProductSettingEntity(product, "mailChimpTemplate", Convert.ToString(_createModel.TemplateMCSelecc));
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_CAMPAIGN_MONITOR)))
            {
                AddProductSettingEntity(product, "campaignMonitorApiToken", _createModel.Token);
                AddProductSettingEntity(product, "campaignMonitorList", _createModel.ListCMSelecc);
                AddProductSettingEntity(product, "campaignMonitorClient", Convert.ToString(_createModel.ClientCMSelecc));
                AddProductSettingEntity(product, "campaignMonitorSegment", Convert.ToString(_createModel.SegmentCMSelecc));
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_AWEBER)))
            {
                AddProductSettingEntity(product, "aweberApiToken", _createModel.Token);
                AddProductSettingEntity(product, "aweberList", _createModel.ListAWSelecc);
                AddProductSettingEntity(product, "aweberApplicationKey", _createModel.providerAWeberApiResult.ApplicationKey);
                AddProductSettingEntity(product, "aweberApplicationSecret", _createModel.providerAWeberApiResult.ApplicationSecret);
                AddProductSettingEntity(product, "aweberOAuthToken", _createModel.providerAWeberApiResult.OAuthToken);
                AddProductSettingEntity(product, "aweberOAuthTokenSecret", _createModel.providerAWeberApiResult.OAuthTokenSecret);
                AddProductSettingEntity(product, "aweberOauthVerifier", _createModel.providerAWeberApiResult.OauthVerifier);
                AddProductSettingEntity(product, "aweberCallbackURL", _createModel.providerAWeberApiResult.CallbackURL);
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_SEND_GRID)))
            {
                AddProductSettingEntity(product, "sendGridApiToken", _createModel.Token);
                AddProductSettingEntity(product, "sendGridList", _createModel.ListSGSelecc);
                AddProductSettingEntity(product, "sendGridSender", _createModel.SenderSGSelecc);
                AddProductSettingEntity(product, "sendGridUnsubscribeGroup", _createModel.UnsubscribeGroupSGSelecc);
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_ACTIVE_CAMPAIGN)))
            {
                AddProductSettingEntity(product, "activeCampaignApiToken", _createModel.Token);
                AddProductSettingEntity(product, "activeCampaignList", _createModel.ListACSelecc);
                AddProductSettingEntity(product, "activeCampaignUrl", _createModel.URLACSelecc);
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_GETRESPONSE)))
            {
                AddProductSettingEntity(product, "getResponseApiToken", _createModel.Token);
                AddProductSettingEntity(product, "getResponseList", _createModel.ListGRSelecc);
                AddProductSettingEntity(product, "getResponseFromField", _createModel.FromFieldGRSelecc);
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_ICONTACT)))
            {
                // Crear campaign y guardar el Id
                string IdCampaign = string.Empty;

                AddProductSettingEntity(product, "icontactIdCampaign", _createModel.IContact.IdCampaign);
                AddProductSettingEntity(product, "icontactApiAppId", _createModel.IContact.ApiAppId);
                AddProductSettingEntity(product, "icontactUserName", _createModel.IContact.ApiUserName);
                AddProductSettingEntity(product, "icontactUserPassword", _createModel.IContact.ApiUserPassword);
                AddProductSettingEntity(product, "icontactAccountId", _createModel.IContact.AccountId);
                AddProductSettingEntity(product, "icontactClientFolderId", _createModel.IContact.ClientFolderId);
                AddProductSettingEntity(product, "icontactIdList", _createModel.IContact.ListId);
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_SENDINBLUE)))
            {
                //Store product settings
                AddProductSettingEntity(product, "sendinBlueApiKey", _createModel.Token);
                AddProductSettingEntity(product, "sendinBlueCategory", _createModel.SendinBlue.Category);
                AddProductSettingEntity(product, "sendinBlueFromEmail", _createModel.SendinBlue.FromEmail);
                AddProductSettingEntity(product, "sendinBlueListId", _createModel.SendinBlue.ListIds[0].ToString());
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_ONE_SIGNAL)))
            {
                AddProductSettingEntity(product, "oneSignalApiKey", _createModel.Token);
                AddProductSettingEntity(product, "oneSignalAppId", _createModel.ListAppOSSelecc);
                AddProductSettingEntity(product, "oneSignalAppKey", _createModel.AuthAppOSSelecc);
            }
            else if (_createModel.ParterTypeSelect.Equals(new Guid(Utils.Constants.PROVIDER_MAILJET)))
            {
                AddProductSettingEntity(product, "mailJetApiKey", _createModel.Token);
                AddProductSettingEntity(product, "mailJetList", _createModel.ListMJSelecc);
                AddProductSettingEntity(product, "mailJetSegment", _createModel.SegmentMJSelecc);
                AddProductSettingEntity(product, "mailJetSecretKey", _createModel.SecretKeyMJ);
            }

            return(true);
        }
示例#16
0
        public bool CreateSite(SiteViewModel viewModel, string userId, out string message, out string IdSite)
        {
            bool result = false;

            IdSite  = string.Empty;
            message = string.Empty;

            //Todo
            var    model          = viewModel;
            string protocolSelecc = viewModel.protocoloSelected;

            model.CategoryTypeSelect = viewModel.categorySelected;
            model.URL = String.IsNullOrEmpty(model.URL) ? "-" : (String.IsNullOrEmpty(protocolSelecc) ? "https://" : protocolSelecc) + model.URL;

            //Create site
            CategoryRepository categoryRepository = new CategoryRepository();
            var            allCategory            = categoryRepository.GetAll();
            CategoryEntity _category = allCategory.FirstOrDefault(x => x.IdCategory == model.CategoryTypeSelect);

            AspNetUserRepository aspNetUserRepository = new AspNetUserRepository();
            AspNetUserEntity     _aspnetuser          = aspNetUserRepository.GetAll().FirstOrDefault(x => x.Id == userId);

            SiteEntity _site = new SiteEntity
            {
                Name   = model.Name,
                URL    = model.URL,
                IdSite = Guid.NewGuid(),

                AspNetUsers_Id     = userId,
                Verified           = false,
                VerificationString = Guid.NewGuid().ToString(),
                RegistrationDate   = DateTime.Now,
                IsActive           = true
            };

            SiteRepository siteRepository = new SiteRepository();


            try
            {
                siteRepository.Add(_site);
                CategorySiteEntity categorySiteEntity = new CategorySiteEntity()
                {
                    CATEGORY_IdCategory = _category.IdCategory,
                    SITEs_IdSite        = _site.IdSite
                };

                CategorySiteRepository categorySiteRepository = new CategorySiteRepository();
                categorySiteRepository.Add(categorySiteEntity);


                IdSite  = _site.IdSite.ToString();
                message = "Site created successfully";
                result  = true;
            }
            catch (Exception e)
            {
                message = "Error creating site";
            }
            return(result);
        }
示例#17
0
 public AspNetUserManager()
 {
     _aspNetUserRepos = new AspNetUserRepository();
 }