Exemplo n.º 1
0
        public ModelViewUser Update(ModelViewUser model)
        {
            var objRepository = new RepositoryUser();

            var dataOld = new RepositoryUser().Get(model.UserID);

            EntityUser data = new EntityUser()
            {
                UserID           = model.UserID,
                ProfileID        = model.ProfileID,
                UserName         = model.UserName,
                Name             = model.Name,
                Password         = dataOld.Password,
                Token            = dataOld.Token,
                ChangePassword   = dataOld.ChangePassword,
                Email            = model.Email,
                Status           = dataOld.Status,
                DateLastAccess   = dataOld.DateLastAccess,
                DateCreate       = dataOld.DateCreate,
                DateModification = DateTime.UtcNow
            };

            data = objRepository.Update(data);

            return(model);
        }
Exemplo n.º 2
0
        public void ChangePassword(ModelViewChangePassword model)
        {
            if (model.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (model.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }

            var objRepo     = new RepositoryUser();
            var dataUsuario = objRepo.GetToken(model.TokenUser);

            if (dataUsuario.Password != new BusinessCryptoMD5(GlobalConfiguration.CryptoKey).CryptoString(model.OldPassword))
            {
                throw new Exception("PasswordOldInvalid");
            }

            if (model.NewPassword != model.ConfirmPassword)
            {
                throw new Exception("ConfirmPassword");
            }

            dataUsuario.Password       = new BusinessCryptoMD5(GlobalConfiguration.CryptoKey).CryptoString(model.NewPassword);
            dataUsuario.ChangePassword = false;

            objRepo.Update(dataUsuario);
        }
Exemplo n.º 3
0
        public void ResetPassword(int ID)
        {
            var objRepo     = new RepositoryUser();
            var dataUsuario = objRepo.Get(ID);

            if (dataUsuario == null)
            {
                throw new Exception("UserInvalid");
            }

            var NewPassword = GeneratePassword(8);

            dataUsuario.Password       = new BusinessCryptoMD5(GlobalConfiguration.CryptoKey).CryptoString(NewPassword);
            dataUsuario.ChangePassword = true;

            objRepo.Update(dataUsuario);

            List <string> arr = new List <string>();

            arr.Add(dataUsuario.Email);

            var objAlerta = new BusinessNotification();

            byte[] outMessage = new byte[ResourceMessage.GetStream("NotificationRecoveryBodyContent").Length];
            ResourceMessage.GetStream("NotificationRecoveryBodyContent").Read(outMessage, 0, (int)ResourceMessage.GetStream("NotificationRecoveryBodyContent").Length);

            StringBuilder sb = new StringBuilder(UnicodeEncoding.Unicode.GetString(outMessage));

            sb = sb.Replace("#%Nombre%#", dataUsuario.Name);
            sb = sb.Replace("#%ClaveTemporal%#", NewPassword);

            //objAlerta.SendMails(arr, ResourceMessage.GetString("NotificationRecoveryPassword"), sb.ToString());
            objAlerta.SendMailExchange(GlobalConfiguration.exchangeUser, GlobalConfiguration.exchangePwd, arr, ResourceMessage.GetString("NotificationRecoveryPassword"), sb.ToString());
        }
Exemplo n.º 4
0
        public ActionResult Update(UserMD Data)
        {
            RepositoryUser repo = new RepositoryUser();
            AuthModel      user = RepositoryAuthModel.GetAuthModel(HttpContext.User.Identity as FormsIdentity);
            OperationResult <UserViewModel> result = repo.Update(Data, user, true);

            return(Json(result));
        }
 public HttpResponseMessage Update(HttpRequestMessage request, UserEntity user)
 {
     try
     {
         using (RepositoryUser rep = new RepositoryUser())
         {
             rep.Update(user);
             rep.SaveAll();
             return(request.CreateResponse(HttpStatusCode.Accepted, user));
         }
     }
     catch (Exception e)
     {
         return(request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message));
     }
 }
Exemplo n.º 6
0
        public void Recovery(ModelViewRecovery model)
        {
            var objRepo     = new RepositoryUser();
            var dataUsuario = objRepo.GetEmail(model.Email);

            if (dataUsuario == null)
            {
                throw new Exception("EmailInvalid");
            }

            var NewPassword = GeneratePassword(8);

            dataUsuario.Password       = new BusinessCryptoMD5(GlobalConfiguration.CryptoKey).CryptoString(NewPassword);
            dataUsuario.ChangePassword = true;

            objRepo.Update(dataUsuario);

            List <string> arr = new List <string>();

            arr.Add(model.Email);
            //arr.Add("*****@*****.**");

            var objAlerta = new BusinessNotification();

            //byte[] outMessage = new byte[ResourceMessage.GetStream("NotificationRecoveryBodyContent", culture).Length];
            //ResourceMessage.GetStream("NotificationRecoveryBodyContent", culture).Read(outMessage, 0, (int) ResourceMessage.GetStream("NotificationRecoveryBodyContent", culture).Length);

            //StringBuilder sb = new StringBuilder(UnicodeEncoding.Unicode.GetString(outMessage));
            string sb = File.ReadAllText(GlobalConfiguration.LocateBodyMail + "NotificationRecoveryBodyContent.txt");

            sb = sb.Replace("#%Nombre%#", dataUsuario.Name);
            sb = sb.Replace("#%ClaveTemporal%#", NewPassword);
            var Manager = new ResourceManager("net.paxialabs.mabe.serviplus.resource.Common.ResourceMessage", typeof(ResourceMessage).Assembly);

            //objAlerta.SendMails(arr, Manager.GetString("NotificationRecoveryPassword"), sb.ToString());
            objAlerta.SendMailExchange(GlobalConfiguration.exchangeUser, GlobalConfiguration.exchangePwd, arr, Manager.GetString("NotificationRecoveryPassword"), sb.ToString());
        }