Beispiel #1
0
        public static int Update(MDonor ent)
        {
            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_Upd", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IDonorId", SqlDbType.VarChar).Value   = ent.DonorId;
                    cmd.Parameters.Add("@IFirstName", SqlDbType.VarChar).Value = ent.FirstName;
                    cmd.Parameters.Add("@ILastName", SqlDbType.VarChar).Value  = ent.LastName;
                    cmd.Parameters.Add("@IEmail", SqlDbType.VarChar).Value     = ent.Email;
                    cmd.Parameters.Add("@ICellphone", SqlDbType.VarChar).Value = ent.Cellphone;
                    cmd.Parameters.Add("@IAddress", SqlDbType.VarChar).Value   = ent.Address;
                    cmd.Parameters.Add("@ICountryId", SqlDbType.Int).Value     = ent.CountryId;
                    cmd.Parameters.Add("@IGender", SqlDbType.VarChar).Value    = ent.Gender;
                    cmd.Parameters.Add("@IBirthday", SqlDbType.Decimal).Value  = ent.Birthday;
                    cmd.Parameters.Add("@IPhoto", SqlDbType.VarChar).Value     = ent.Photo;
                    cmd.Parameters.Add("@IStatus", SqlDbType.Int).Value        = ent.Status;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    return(0);
                }

                catch (Exception ex)
                {
                    return(2);
                }
            }
        }
Beispiel #2
0
        public static int UpdateCode(MDonor ent)
        {
            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_CodeUpd", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IPassword", SqlDbType.VarChar).Value = ent.Password;
                    cmd.Parameters.Add("@IEmail", SqlDbType.VarChar).Value    = ent.Email;
                    cmd.Parameters.Add("@IToken", SqlDbType.VarChar).Value    = ent.Token;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    return(0);
                }

                catch (Exception ex)
                {
                    return(2);
                }
            }
        }
Beispiel #3
0
        public static int ChangePassword(MDonor ent)
        {
            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_ChangePassword", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IDonorId", SqlDbType.VarChar).Value     = ent.DonorId;
                    cmd.Parameters.Add("@IOldPassword", SqlDbType.VarChar).Value = ent.OldPassword;
                    cmd.Parameters.Add("@IEmail", SqlDbType.VarChar).Value       = ent.Email; //cmd.Parameters.Add("@ICellphone", SqlDbType.VarChar).Value = ent.Cellphone;
                    cmd.Parameters.Add("@INewPassword", SqlDbType.VarChar).Value = ent.Password;
                    cmd.Parameters.Add("@OResult", SqlDbType.Int).Direction      = ParameterDirection.Output;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    int Result = Convert.ToInt32(cmd.Parameters["@OResult"].Value);
                    con.Close();

                    return(Result);
                }

                catch (Exception ex)
                {
                    return(2);
                }
            }
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public static List <MDonor> Lis(MDonor ent, ref int Val)
        {
            List <MDonor> lisQuery = new List <MDonor>();

            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_Lis", con);
                    cmd.Parameters.Add("@IFirstName", SqlDbType.VarChar).Value = ent.FirstName;
                    cmd.Parameters.Add("@ILastName", SqlDbType.VarChar).Value  = ent.LastName;
                    cmd.Parameters.Add("@ICountryId", SqlDbType.Int).Value     = ent.CountryId;
                    cmd.Parameters.Add("@IRegistered", SqlDbType.Int).Value    = ent.Registered;
                    cmd.Parameters.Add("@IStatus", SqlDbType.Int).Value        = ent.Status;
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    con.Open();

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            MDonor entRow = new MDonor();
                            entRow.DonorId   = Convert.ToInt32(reader["DonorId"]);
                            entRow.FirstName = Convert.ToString(reader["FirstName"]);
                            entRow.LastName  = Convert.ToString(reader["LastName"]);
                            entRow.Email     = Convert.ToString(reader["Email"]);
                            //entRow.Password = Convert.ToString(reader["Password"]);
                            entRow.Cellphone  = Convert.ToString(reader["Cellphone"]);
                            entRow.Address    = Convert.ToString(reader["Address"]);
                            entRow.CountryId  = Convert.ToInt32(reader["CountryId"]);
                            entRow.Country    = Convert.ToString(reader["Country"]);
                            entRow.Continent  = Convert.ToString(reader["Continent"]);
                            entRow.Gender     = Convert.ToString(reader["Gender"]);
                            entRow.Birthday   = Convert.ToDecimal(reader["Birthday"]);
                            entRow.Registered = Convert.ToInt32(reader["Registered"]);
                            entRow.Status     = Convert.ToInt32(reader["Status"]);

                            lisQuery.Add(entRow);

                            Val = 0;
                        }
                    }
                    con.Close();
                }

                catch (SqlException ex)
                {
                    Val = 2;
                }
            }
            return(lisQuery);
        }
Beispiel #6
0
        public DonorResponse LoginDonor([FromBody] DonorRequest request)
        {
            DonorResponse response    = new DonorResponse();
            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; //Se comenta el logeo por Email
                donor.Email    = request.Donor.Email;
                donor.Password = UEncrypt.Encrypt(request.Donor.Password);

                int CodeResult = 0;
                donor = BDonor.Login(donor, ref CodeResult);

                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 session data is invalid.";
                }
                else
                {
                    response.Message = "An error occurred when logging in";
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
Beispiel #7
0
        public static MDonor Login(MDonor ent, ref int Val)
        {
            MDonor result = new MDonor();

            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_Login", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IEmail", SqlDbType.VarChar).Value    = ent.Email;
                    cmd.Parameters.Add("@IPassword", SqlDbType.VarChar).Value = ent.Password;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();

                    Val = 1;

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            result.DonorId   = Convert.ToInt32(reader["DonorId"]);
                            result.FirstName = Convert.ToString(reader["FirstName"]);
                            result.LastName  = Convert.ToString(reader["LastName"]);
                            result.Email     = Convert.ToString(reader["Email"]);

                            result.Password  = Convert.ToString(reader["Password"]);
                            result.Cellphone = Convert.ToString(reader["Cellphone"]);
                            result.Address   = Convert.ToString(reader["Address"]);
                            result.CountryId = Convert.ToInt32(reader["CountryId"]);
                            result.Birthday  = Convert.ToDecimal(reader["Birthday"]);
                            result.Photo     = (Convert.ToString(reader["Photo"]).Equals("")) ? "" : Constant.S3Server + Convert.ToString(reader["Photo"]);
                            result.Token     = Convert.ToString(reader["Token"]);

                            Val = 0;
                        }
                    }
                    con.Close();
                }

                catch (Exception ex)
                {
                    Val = 2;
                }
            }
            return(result);
        }
Beispiel #8
0
        public static int Insert(MDonor ent, BaseRequest baseRequest, ref int DonorId)
        {
            int Registered = 0;

            int Result = DADonor.ValidateInsert(ent.Cellphone, ent.Email, ref Registered, ref DonorId);

            ent.Registered = Registered;

            if (Result == 0)
            {
                return(DADonor.Insert(ent, baseRequest));
            }
            else
            {
                return(Result);
            }
        }
Beispiel #9
0
        public DonorResponse DeleteDonor([FromBody] DonorRequest request)
        {
            DonorResponse response = new DonorResponse();
            MDonor        donor    = new MDonor();

            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;

                int CodeResult = BDonor.Delete(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.ErrorDelete, "Donor");
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
Beispiel #10
0
        public static MDonor ValidateDonor(MDonor ent, ref int Val)
        {
            MDonor result = new MDonor();

            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_ValUser", con);
                    cmd.CommandTimeout = 0;
                    //cmd.Parameters.Add("@ICellphone", SqlDbType.VarChar).Value = ent.Cellphone;
                    cmd.Parameters.Add("@IEmail", SqlDbType.VarChar).Value = ent.Email;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();

                    Val = 1;

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            result.Email     = Convert.ToString(reader["Email"]);
                            result.Cellphone = Convert.ToString(reader["Cellphone"]);
                            result.CountryId = Convert.ToInt32(reader["CountryId"]);

                            Val = 0;
                        }
                    }
                    con.Close();
                }

                catch (Exception ex)
                {
                    Val = 2;
                }
            }
            return(result);
        }
Beispiel #11
0
        public static List <MProjectDonation> List(MDonor ent, BaseRequest baseRequest)
        {
            List <MProjectDonation> lisQuery = new List <MProjectDonation>();

            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_ProjectDonation_Lis", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IDonorId", SqlDbType.VarChar).Value  = ent.DonorId;
                    cmd.Parameters.Add("@ILanguage", SqlDbType.VarChar).Value = baseRequest.Language;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            MProjectDonation entRow = new MProjectDonation();
                            entRow.DonationId = Convert.ToInt32(reader["DonationId"]);
                            entRow.Date       = Convert.ToString(reader["Date"]);
                            entRow.ProjectId  = Convert.ToInt32(reader["ProjectId"]);
                            entRow.Title      = Convert.ToString(reader["Title"]);
                            entRow.Amount     = Convert.ToDecimal(reader["Amount"]);
                            entRow.Image      = (Convert.ToString(reader["Image"]).Equals("")) ? "" : Constant.S3Server + Convert.ToString(reader["Image"]);
                            lisQuery.Add(entRow);
                        }
                    }
                    con.Close();
                }

                catch (SqlException ex)
                {
                }
            }
            return(lisQuery);
        }
Beispiel #12
0
        public static int Insert(MDonor ent, BaseRequest baseRequest)
        {
            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_Ins", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IFirstName", SqlDbType.VarChar).Value = ent.FirstName;
                    cmd.Parameters.Add("@ILastName", SqlDbType.VarChar).Value  = ent.LastName;
                    cmd.Parameters.Add("@IEmail", SqlDbType.VarChar).Value     = ent.Email;
                    cmd.Parameters.Add("@IPassword", SqlDbType.VarChar).Value  = ent.Password;
                    cmd.Parameters.Add("@ICellphone", SqlDbType.VarChar).Value = ent.Cellphone;
                    cmd.Parameters.Add("@IAddress", SqlDbType.VarChar).Value   = ent.Address;
                    cmd.Parameters.Add("@ICountryId", SqlDbType.Int).Value     = ent.CountryId;
                    cmd.Parameters.Add("@IGender", SqlDbType.VarChar).Value    = ent.Gender;
                    cmd.Parameters.Add("@IBirthday", SqlDbType.Decimal).Value  = ent.Birthday;
                    cmd.Parameters.Add("@IPhoto", SqlDbType.DateTime).Value    = ent.Photo;
                    cmd.Parameters.Add("@IStatus", SqlDbType.Int).Value        = ent.Status;
                    cmd.Parameters.Add("@IToken", SqlDbType.VarChar).Value     = ent.Token;
                    cmd.Parameters.Add("@ODonorID", SqlDbType.Int).Direction   = ParameterDirection.Output;
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    ent.DonorId = Convert.ToInt32(cmd.Parameters["@ODonorID"].Value);
                    con.Close();

                    return(0);
                }

                catch (Exception ex)
                {
                    return(2);
                }
            }
        }
Beispiel #13
0
        public static int Delete(MDonor ent)
        {
            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_Donor_Del", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IDonorId", SqlDbType.VarChar).Value = ent.Cellphone;

                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    return(0);
                }

                catch (Exception ex)
                {
                    return(2);
                }
            }
        }
Beispiel #14
0
 public static int UpdateCode(MDonor ent)
 {
     return(DADonor.UpdateCode(ent));
 }
Beispiel #15
0
 public static List <MDonor> List(MDonor ent, ref int Val)
 {
     return(DADonor.Lis(ent, ref Val));
 }
Beispiel #16
0
 public static int Delete(MDonor ent)
 {
     return(DADonor.Delete(ent));
 }
Beispiel #17
0
 public static MDonor Select(MDonor ent, ref int Val)
 {
     return(DADonor.Select(ent, ref Val));
 }
Beispiel #18
0
 public static MDonor Login(MDonor ent, ref int Val)
 {
     return(DADonor.Login(ent, ref Val));
 }
Beispiel #19
0
        public CreateDonorResponse ResetPassword([FromBody] DonorRequest request)
        {
            CreateDonorResponse response = new CreateDonorResponse();
            MDonor donor = new MDonor();

            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.Email = request.Donor.Email;

                int refval = 0;

                donor = BDonor.ValidateDonor(donor, ref refval);

                if (refval.Equals(0))
                {
                    donor.Password = UEncrypt.Encrypt(UCommon.RandomNumber(1000, 9999).ToString());
                    donor.Token    = UCommon.GetTokem();

                    MCountry countryBE = new MCountry();
                    countryBE.CountryId = donor.CountryId;
                    countryBE           = BCountry.Select(countryBE, ref refval);

                    if (BDonor.UpdateCode(donor) == 0)
                    {
                        if (!request.Donor.Email.Equals(""))
                        {
                            SendSES(donor.Password, donor.Email);
                        }

                        response.Code    = "0";
                        response.Message = Messages.Success;
                    }
                    else
                    {
                        response.Code    = "2";
                        response.Message = String.Format(Messages.ErrorInsert, "Donor");
                    }
                }
                else
                {
                    donor.Cellphone = request.Donor.Cellphone;
                    donor.Email     = request.Donor.Email;
                    response.Code   = "1";

                    if (!donor.Email.Equals(""))
                    {
                        response.Message = "The email entered is not registered";
                    }
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
Beispiel #20
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);
        }
Beispiel #21
0
 public static MDonor ValidateDonor(MDonor ent, ref int Val)
 {
     return(DADonor.ValidateDonor(ent, ref Val));
 }
Beispiel #22
0
        public CreateDonorResponse CreateDonor([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(UCommon.RandomNumber(1000, 9999).ToString());
                //donor.CountryId = request.Donor.CountryId;
                donor.Token  = UCommon.GetTokem();
                donor.Status = 1;

                baseRequest.Session = request.Session;

                int DonorId = 0;

                int CodeResult = BDonor.Insert(donor, baseRequest, ref DonorId);

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

                if (CodeResult == 0)
                {
                    response.Message = Messages.Success;
                    //SendSNS(donor.Password, donor.Cellphone, countryBE.Prefix);
                    SendSES(donor.Password, donor.Email);
                }
                else if (CodeResult == 1)
                {
                    if (donor.Registered == 0)
                    {
                        if (BDonor.UpdateCode(donor) == 0)
                        {
                            donor.DonorId = DonorId;

                            response.Code    = "0";
                            response.Message = Messages.Success;
                            //SendSNS(donor.Password, donor.Cellphone, countryBE.Prefix);
                            SendSES(donor.Password, donor.Email);
                        }
                        else
                        {
                            response.Message = String.Format(Messages.ErrorInsert, "Donor");
                        }
                    }
                    else
                    {
                        //response.Message = "The cell phone number and email entered are already used.";
                        response.Message = "The email entered are already used.";
                    }
                }
                else
                {
                    response.Message = String.Format(Messages.ErrorInsert, "Donor");
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            response.Donor = donor;

            return(response);
        }
Beispiel #23
0
 public static int ValidateCode(MDonor ent)
 {
     return(DADonor.ValidateCode(ent));
 }
Beispiel #24
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 #25
0
 public static int ChangePassword(MDonor ent)
 {
     return(DADonor.ChangePassword(ent));
 }
Beispiel #26
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 #27
0
 public static List <MProjectDonation> List(MDonor ent, BaseRequest baseRequest)
 {
     return(DAProjectDonation.List(ent, baseRequest));
 }