Beispiel #1
0
        public CreateDonorResponse ChangePasswordDonor([FromBody] DonorRequest request)
        {
            CreateDonorResponse response = new CreateDonorResponse();
            MDonor      donor            = new MDonor();
            BaseRequest baseRequest      = new BaseRequest();

            try
            {
                /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }
                /*************FIN DEL METODO*************/

                donor.DonorId     = request.Donor.DonorId;
                donor.Email       = request.Donor.Email;//donor.Cellphone = request.Donor.Cellphone;
                donor.Password    = UEncrypt.Encrypt(request.Donor.Password);
                donor.OldPassword = UEncrypt.Encrypt(request.Donor.OldPassword);

                baseRequest.Session = request.Session;

                if (BSession.ValidateSession(1, baseRequest.Session.Token, baseRequest.Session.UserId).Equals(1))
                {
                    int CodeResult = BDonor.ChangePassword(donor);
                    response.Code = CodeResult.ToString(); //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción

                    if (CodeResult == 0)
                    {
                        response.Message = Messages.Success;
                    }
                    else if (CodeResult == 1)
                    {
                        response.Message = "The old password entered is invalid";
                    }
                    else
                    {
                        response.Message = "An error occurred when changing the password";
                    }
                }
                else
                {
                    response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.ApplicationTokenNoAutorize;
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
        public async void UpdateIP()
        {
            string stIP = await Network.GetExternalIPAsync();

            if (!string.IsNullOrEmpty(stIP))
            {
                BSession.ChangeIpSession(ObjSession, Convert.ToByte(stIP.Split('.')[0]), Convert.ToByte(stIP.Split('.')[1]), Convert.ToByte(stIP.Split('.')[2]), Convert.ToByte(stIP.Split('.')[3]));
            }
        }
        private void Form_004_FormClosed(object sender, FormClosedEventArgs e)
        {
            timClock.Enabled = TimSession.Enabled = false;

            Business.FreeAllRegistersAssociatedWithThisUser(ObjUser);
            BSession.UpdateLastTimeSession(ObjSession);

            //CloseWindows();

            objForm_002.ObjForm_001.Close();
        }
Beispiel #4
0
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if (!string.IsNullOrEmpty(txtUser.Text) && !string.IsNullOrEmpty(txtPassword.Text))
            {
                var vUser = BUser.FindAndValidateByUserNameOrEmailOrCellphone(txtUser.Text, txtPassword.Text);

                if (vUser != null)
                {
                    var vSession = BSession.CreateSession(vUser);

                    if (vSession != null)
                    {
                        Hide();
                        objForm_004 = new Form_004(this, vUser, vSession);
                        objForm_004.Show();
                    }
                    else
                    {
                        Cursor = Cursors.Default;
                        MessageBox.Show("There was an unknown error, try to exit this application and then entry again.", Preferences.TitleSoftware, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Cursor = Cursors.Default;
                    MessageBox.Show("Didn't find any user with these data.", Preferences.TitleSoftware, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtUser.Focus();
                }
            }
            else
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The user's data aren't incorrect.", Preferences.TitleSoftware, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtUser.Focus();
            }

            Cursor = Cursors.Default;
        }
Beispiel #5
0
        public DonorResponse GetDonor([FromBody] DonorRequest request)
        {
            DonorResponse           response    = new DonorResponse();
            MDonor                  donor       = new MDonor();
            List <MProjectDonation> Donations   = new List <MProjectDonation>();
            BaseRequest             baseRequest = new BaseRequest();

            try
            {
                /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }
                /*************FIN DEL METODO*************/

                donor.DonorId       = request.Donor.DonorId;
                baseRequest.Session = request.Session;

                if (BSession.ValidateSession(1, baseRequest.Session.Token, baseRequest.Session.UserId).Equals(1))
                {
                    int CodeResult = 0;
                    donor = BDonor.Select(donor, ref CodeResult);

                    response.Code = CodeResult.ToString(); //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción

                    Donations = BProjectDonation.List(donor, baseRequest);

                    response.DonationsCounter = Donations.Count;

                    if (CodeResult == 0)
                    {
                        response.Message = Messages.Success;
                    }
                    else if (CodeResult == 1)
                    {
                        response.Message = String.Format(Messages.NoExistsSelect, "Donor");
                    }
                    else
                    {
                        response.Message = String.Format(Messages.ErrorSelect, "Donor");
                    }
                }
                else
                {
                    response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.ApplicationTokenNoAutorize;
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
Beispiel #6
0
        public CreateDonorResponse UpdateDonor([FromBody] DonorRequest request)
        {
            CreateDonorResponse response = new CreateDonorResponse();
            MDonor      donor            = new MDonor();
            BaseRequest baseRequest      = new BaseRequest();

            try
            {
                /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }
                /*************FIN DEL METODO*************/

                string webRoot   = _env.ContentRootPath;
                string rootPath  = _appSettings.Value.rootPath;
                string DonorPath = _appSettings.Value.DonorPath;

                donor.DonorId   = request.Donor.DonorId;
                donor.Cellphone = request.Donor.Cellphone;
                donor.Email     = request.Donor.Email;
                donor.CountryId = request.Donor.CountryId;
                donor.FirstName = request.Donor.FirstName;
                donor.LastName  = request.Donor.LastName;
                donor.Gender    = request.Donor.Gender;
                donor.Birthday  = request.Donor.Birthday;
                donor.Address   = request.Donor.Address;
                donor.Photo     = DonorPath + "/" + request.Donor.Photo.Replace(Constant.S3Server, string.Empty).Replace(DonorPath + "/", string.Empty);
                donor.Status    = 1;

                baseRequest.Session = request.Session;

                byte[] FileByte = request.FileByte ?? Encoding.ASCII.GetBytes("");

                if (BSession.ValidateSession(1, baseRequest.Session.Token, baseRequest.Session.UserId).Equals(1))
                {
                    if (!FileByte.Length.Equals(0))
                    {
                        try
                        {
                            donor.Photo = donor.DonorId.ToString() + request.PhotoExtension;

                            //Grabamos el archivo
                            Uri    webRootUri = new Uri(webRoot);
                            string path       = webRootUri.AbsolutePath + rootPath + DonorPath;

                            var pathSave = Path.Combine(path, donor.Photo);

                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }

                            if (System.IO.File.Exists(pathSave))
                            {
                                System.IO.File.Delete(pathSave);
                            }

                            System.IO.File.WriteAllBytes(pathSave, FileByte);

                            if (!BAwsSDK.UploadS3(_MAwsS3, pathSave, DonorPath, donor.Photo))
                            {
                                response.Message = String.Format(Messages.ErrorLoadPhoto, "Donor");
                            }

                            System.IO.File.Delete(pathSave);

                            donor.Photo = DonorPath + "/" + donor.Photo;
                        }
                        catch (Exception ex)
                        {
                            response.Message = String.Format(Messages.ErrorUpdate, "Banner") + ex.Message;
                            response.Donor   = donor;
                            return(response);
                        }
                    }

                    int CodeResult = BDonor.Update(donor);

                    response.Code = CodeResult.ToString(); //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción

                    if (CodeResult == 0)
                    {
                        response.Message = Messages.Success;
                    }
                    else
                    {
                        response.Message = String.Format(Messages.ErrorUpdate, "Banner");
                    }
                }
                else
                {
                    response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.ApplicationTokenNoAutorize;
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor       = donor;
            response.Donor.Token = request.Session.Token;

            return(response);
        }
Beispiel #7
0
        public CreateDonorResponse ValidateDonor([FromBody] DonorRequest request)
        {
            CreateDonorResponse response = new CreateDonorResponse();
            MDonor      donor            = new MDonor();
            BaseRequest baseRequest      = new BaseRequest();

            try
            {
                /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }
                /*************FIN DEL METODO*************/

                //donor.Cellphone = request.Donor.Cellphone;
                donor.Email    = request.Donor.Email;
                donor.Password = UEncrypt.Encrypt(request.Donor.Password);

                baseRequest.Session = request.Session;

                donor.DonorId = request.Session.UserId;

                if (BSession.ValidateSession(1, baseRequest.Session.Token, baseRequest.Session.UserId).Equals(1))
                {
                    int CodeResult = BDonor.ValidateCode(donor);

                    response.Code = CodeResult.ToString(); //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción

                    if (CodeResult == 0)
                    {
                        response.Message = Messages.Success;
                        SendSESValidate(donor.Email);
                        donor = BDonor.Select(donor, ref CodeResult);
                    }
                    else if (CodeResult == 1)
                    {
                        response.Message = "The code entered is not valid.";
                    }
                    else if (CodeResult == 3)
                    {
                        response.Code    = "1";
                        response.Message = "The Donor is already validated.";
                    }
                    else
                    {
                        response.Message = "The Donor is already validated.";
                    }
                }
                else
                {
                    response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.ApplicationTokenNoAutorize;
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
 private async void UpdateDateSession()
 {
     await BSession.UpdateLastDateSessionAsync(ObjSession);
 }