Exemplo n.º 1
0
        public FundsResponse GetFunds([FromBody] BaseRequest request)
        {
            FundsResponse response = new FundsResponse();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                List <MFund> funds = BFund.List();

                response.Funds   = funds.ToArray();
                response.Code    = "0";
                response.Message = "Success";
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 2
0
        public ProgramNamesResponse GetProgramNames([FromBody] BaseRequest request)
        {
            ProgramNamesResponse response = new ProgramNamesResponse();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                List <MProgramName> programNames = BProgramName.List();

                response.ProgramNames = programNames.ToArray();
                response.Code         = "0";
                response.Message      = "Success";
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 3
0
        public ProjectsResponse GetProjects([FromBody] ProjectRequest request)
        {
            ProjectsResponse response = new ProjectsResponse();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                MProject project = new MProject();
                project.Status    = request.Project.Status;
                project.Title     = request.Project.Title;
                project.StartDate = request.Project.StartDate;
                project.EndDate   = request.Project.EndDate;

                List <MProject> projects = BProject.List(project);

                response.Code     = "0";
                response.Message  = "Success";
                response.Projects = projects.ToArray();
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 4
0
        public ProjectPropertiesResponse ProjectProperties([FromBody] BaseRequest request)
        {
            ProjectPropertiesResponse response = new ProjectPropertiesResponse();

            List <MProgramName>  programNames  = new List <MProgramName>();
            List <MDonorPartner> donorPartners = new List <MDonorPartner>();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                programNames  = BProgramName.List();
                donorPartners = BDonorPartner.List();

                response.Code          = "0";
                response.Message       = "Success";
                response.ProgramNames  = programNames.ToArray();
                response.DonorPartners = donorPartners.ToArray();
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 5
0
        public ProjectFinancialPropertiesResponse ProjectFinancialProperties([FromBody] BaseRequest request)
        {
            ProjectFinancialPropertiesResponse response = new ProjectFinancialPropertiesResponse();

            List <MDeparment>       deparments        = new List <MDeparment>();
            List <MFund>            funds             = new List <MFund>();
            List <MImplementAgency> implementAgencies = new List <MImplementAgency>();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                deparments        = BDeparment.List();
                funds             = BFund.List();
                implementAgencies = BImplementAgency.List();

                response.Code              = "0";
                response.Message           = "Success";
                response.Deparments        = deparments.ToArray();
                response.Funds             = funds.ToArray();
                response.ImplementAgencies = implementAgencies.ToArray();
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 6
0
        public ImplementAgenciesResponse GetImplementAgencies([FromBody] BaseRequest request)
        {
            ImplementAgenciesResponse response = new ImplementAgenciesResponse();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                List <MImplementAgency> ImplementAgencies = BImplementAgency.List();

                response.ImplementAgencies = ImplementAgencies.ToArray();
                response.Code    = "0";
                response.Message = "Success";
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 7
0
        public DeparmentsResponse GetDeparments([FromBody] BaseRequest request)
        {
            DeparmentsResponse response = new DeparmentsResponse();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                List <MDeparment> deparments = BDeparment.List();

                response.Deparments = deparments.ToArray();
                response.Code       = "0";
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 8
0
        public DonorPartnersResponse GetDonorPartners([FromBody] BaseRequest request)
        {
            DonorPartnersResponse response = new DonorPartnersResponse();

            try
            {
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }

                List <MDonorPartner> donorpartners = BDonorPartner.List();

                response.DonorPartners = donorpartners.ToArray();
                response.Code          = "0";
                response.Message       = "Success";
            }
            catch (Exception ex)
            {
                response.Code    = "2";
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        public ProjectResponse InsertProject([FromBody] ProjectsRequest request)
        {
            ProjectResponse response = new ProjectResponse();

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                    {
                        response.Code    = "2";
                        response.Message = Messages.ApplicationTokenNoAutorize;
                        return(response);
                    }

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

                    BaseRequest baseRequest = new BaseRequest();

                    foreach (MProject model in request.Projects)
                    {
                        MProject project = new MProject();

                        project.ProjectCode = model.ProjectCode;
                        project.Description = model.Description;
                        project.Type        = model.Type;
                        project.Status      = model.Status;
                        project.StartDate   = model.StartDate;
                        project.EndDate     = model.EndDate;
                        project.Title       = model.Title;
                        project.AwardId     = model.AwardId;
                        project.AwardStatus = model.AwardStatus;

                        BProject.Insert(project);
                    }

                    response.Code    = "0";
                    response.Message = "Success";

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    response.Code    = "2";
                    response.Message = ex.Message;

                    scope.Dispose();
                }
            }

            return(response);
        }
Exemplo n.º 11
0
        public UserResponse ChangePassword([FromBody] UserRequest request)
        {
            UserResponse response = new UserResponse();
            MUser        user     = new MUser();

            BaseRequest baseRequest = new BaseRequest();

            try
            {
                baseRequest.Session = request.Session;

                /*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*************/

                user.UserId   = request.User.UserId;
                user.Password = UEncrypt.Encrypt(UCommon.RandomNumber(1000, 9999).ToString());
                user.Token    = UCommon.GetTokem();

                string Password = user.Password;
                int    Val      = 0;

                BUser.ChangePassword(user, ref Val);

                if (Val.Equals(0))
                {
                    user = BUser.Sel(user, ref Val);

                    response.Code    = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.Success;

                    SendEmail(Password, user.User);
                }
                else if (Val.Equals(2))
                {
                    response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = "Failed to change password.";
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = ex.Message;
            }

            response.User = user;

            return(response);
        }
Exemplo n.º 12
0
        public UserResponse InsertUser([FromBody] UserRequest request)
        {
            UserResponse response = new UserResponse();
            MUser        user     = new MUser();

            try
            {
                BaseRequest baseRequest = new BaseRequest();
                baseRequest.Session = request.Session;

                /*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*************/

                user.Type     = request.User.Type;
                user.User     = request.User.User;
                user.Name     = request.User.Name;
                user.Status   = request.User.Status;
                user.Password = UEncrypt.Encrypt(UCommon.RandomNumber(1000, 9999).ToString());
                user.Token    = UCommon.GetTokem();

                int Val = 0;

                BUser.Insert(user, ref Val);

                if (Val.Equals(0))
                {
                    response.Code    = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.Success;

                    SendEmail(user.Password, user.User);
                }
                else if (Val.Equals(2))
                {
                    response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = String.Format(Messages.ErrorInsert, "User");
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = ex.Message;
            }

            response.User = user;

            return(response);
        }
Exemplo n.º 13
0
        public UserResponse LoginUser([FromBody] UserRequest request)
        {
            UserResponse response = new UserResponse();
            MUser        user     = new MUser();

            BaseRequest baseRequest = new BaseRequest();

            try
            {
                baseRequest.Session = request.Session;

                /*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*************/

                user.User     = request.User.User;
                user.Password = UEncrypt.Encrypt(request.User.Password);

                int Val = 0;

                user = BUser.Login(user, ref Val);

                if (Val.Equals(0))
                {
                    response.Code    = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.Success;
                }
                else if (Val.Equals(2))
                {
                    response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = String.Format(Messages.ErrorSelect, "User");
                }
                else if (Val.Equals(1))
                {
                    response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = "User does not exist";
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = ex.Message;
            }

            response.User = user;

            return(response);
        }
Exemplo n.º 14
0
        public UsersProfileResponse GetUsersUnAssigned([FromBody] ProfileUserRequest request)
        {
            UsersProfileResponse response    = new UsersProfileResponse();
            MProfileUser         profile     = new MProfileUser();
            List <MProfileUser>  profiles    = new List <MProfileUser>();
            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*************/

                profile.ProfileId = request.ProfileUser.ProfileId;
                profile.User      = request.ProfileUser.User;
                profile.Name      = request.ProfileUser.Name;

                int Val = 0;

                profiles = BProfile.LisUsersUnAssigned(profile, ref Val);

                if (Val.Equals(0))
                {
                    response.Code    = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.Success;
                }
                else if (Val.Equals(2))
                {
                    response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = String.Format(Messages.ErrorObtainingReults, "Users UnAssigned");
                }
                else
                {
                    response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = String.Format(Messages.NotReults, "Users UnAssigned");
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = ex.Message;
            }

            response.UsersProfile = profiles.ToArray();

            return(response);
        }
Exemplo n.º 15
0
        public ProfileResponse InsertProfile([FromBody] ProfileRequest request)
        {
            ProfileResponse        response = new ProfileResponse();
            MProfile               profile  = new MProfile();
            List <MProfileOptions> options  = new List <MProfileOptions>();

            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*************/

                BaseRequest baseRequest = new BaseRequest();

                profile.Description = request.Profile.Description;

                foreach (MProfileOptions item in request.Options)
                {
                    options.Add(item);
                }

                int ProfileId = 0;
                int Val       = BProfile.Insert(profile, options, ref ProfileId);

                profile.ProfileId = ProfileId;

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

            response.Profile = profile;

            return(response);
        }
Exemplo n.º 16
0
        public UserResponse UpdatetUser([FromBody] UserRequest request)
        {
            UserResponse response = new UserResponse();
            MUser        user     = new MUser();

            try
            {
                BaseRequest baseRequest = new BaseRequest();

                baseRequest.Session = request.Session;

                /*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*************/

                user.UserId = request.User.UserId;
                user.User   = request.User.User;
                user.Name   = request.User.Name;
                user.Status = request.User.Status;

                int Val = 0;

                BUser.Update(user, ref Val);

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


            response.User = user;

            return(response);
        }
Exemplo n.º 17
0
        public BaseResponse InsertProgramName([FromBody] ProgramNamesRequest request)
        {
            BaseResponse response = new BaseResponse();

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                    {
                        response.Code    = "2";
                        response.Message = Messages.ApplicationTokenNoAutorize;
                        return(response);
                    }

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

                    BaseRequest baseRequest = new BaseRequest();

                    foreach (MProgramName model in request.ProgramNames)
                    {
                        MProgramName programName = new MProgramName();

                        programName.ProjectCode    = model.ProjectCode;
                        programName.ProgramName    = model.ProgramName;
                        programName.DonorCode      = model.DonorCode;
                        programName.ProjectDetails = model.ProjectDetails;
                        programName.Sector         = model.Sector;
                        programName.TaskManager    = model.TaskManager;

                        BProgramName.Insert(programName);
                    }

                    response.Code    = "0";
                    response.Message = "Success";
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    response.Code    = "2";
                    response.Message = ex.Message;

                    scope.Dispose();
                }
            }

            return(response);
        }
Exemplo n.º 18
0
        public OptionsResponse GetOptionsByProfile([FromBody] OptionsRequest request)
        {
            OptionsResponse response = new OptionsResponse();
            MOptions        option   = new MOptions();
            List <MOptions> options  = new List <MOptions>();

            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*************/

                option.ProfileId = request.Options.ProfileId;

                int Val = 0;

                options = BOptions.Sel(option, ref Val);

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

            response.Options = options.ToArray();

            return(response);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
        public BaseResponse InsertDeparment([FromBody] DeparmentsRequest request)
        {
            BaseResponse response = new BaseResponse();

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                    {
                        response.Code    = "2";
                        response.Message = Messages.ApplicationTokenNoAutorize;
                        return(response);
                    }

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

                    BaseRequest baseRequest = new BaseRequest();

                    foreach (MDeparment model in request.Deparments)
                    {
                        MDeparment Deparment = new MDeparment();

                        Deparment.DeparmentCode = model.DeparmentCode;
                        Deparment.Description   = model.Description;
                        Deparment.PracticeArea  = model.PracticeArea;
                        Deparment.Region        = model.Region;

                        BDeparment.Insert(Deparment);
                    }

                    scope.Complete();
                    response.Code    = "0";
                    response.Message = "Success";
                }
                catch (Exception ex)
                {
                    response.Code    = "2";
                    response.Message = ex.Message;

                    scope.Dispose();
                }
            }

            return(response);
        }
Exemplo n.º 21
0
        public BaseResponse InsertImplementAgency([FromBody] ImplementAgenciesRequest request)
        {
            BaseResponse response = new BaseResponse();

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                    {
                        response.Code    = "2";
                        response.Message = Messages.ApplicationTokenNoAutorize;
                        return(response);
                    }

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

                    BaseRequest baseRequest = new BaseRequest();

                    foreach (MImplementAgency model in request.ImplementAgencies)
                    {
                        MImplementAgency fund = new MImplementAgency();

                        fund.ImplementAgencyCode = model.ImplementAgencyCode;
                        fund.Description         = model.Description;
                        fund.ShortDescription    = model.ShortDescription;

                        BImplementAgency.Insert(fund);
                    }

                    scope.Complete();
                    response.Code    = "0";
                    response.Message = "Success";
                }
                catch (Exception ex)
                {
                    response.Code    = "2";
                    response.Message = ex.Message;

                    scope.Dispose();
                }
            }

            return(response);
        }
Exemplo n.º 22
0
        public BaseResponse InsertDonorPartner([FromBody] DonorPartnersRequest request)
        {
            BaseResponse response = new BaseResponse();

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                    {
                        response.Code    = "2";
                        response.Message = Messages.ApplicationTokenNoAutorize;
                        return(response);
                    }

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

                    BaseRequest baseRequest = new BaseRequest();

                    foreach (MDonorPartner model in request.DonorPartners)
                    {
                        MDonorPartner DonorPartner = new MDonorPartner();

                        DonorPartner.DonorCode      = model.DonorCode;
                        DonorPartner.DonorName      = model.DonorName;
                        DonorPartner.FundingPartner = model.FundingPartner;

                        BDonorPartner.Insert(DonorPartner);
                    }

                    scope.Complete();
                    response.Code    = "0";
                    response.Message = "Success";
                }
                catch (Exception ex)
                {
                    response.Code    = "2";
                    response.Message = ex.Message;

                    scope.Dispose();
                }
            }

            return(response);
        }
Exemplo n.º 23
0
        public ProfileResponse DeleteProfile([FromBody] ProfileRequest request)
        {
            ProfileResponse response    = new ProfileResponse();
            BaseRequest     baseRequest = new BaseRequest();
            MProfile        profile     = new MProfile();

            try
            {
                baseRequest.Language = request.Language;
                baseRequest.Session  = request.Session;

                /*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*************/

                profile.ProfileId = request.Profile.ProfileId;

                int Val = 0;

                profile.ProfileId = BProfile.Delete(profile, ref Val);

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

            response.Profile = profile;

            return(response);
        }
Exemplo n.º 24
0
        public UserProfileResponse RegisterUsersProfile([FromBody] ProfileUserRequest request)
        {
            UserProfileResponse response = new UserProfileResponse();
            MProfileUser        profile  = new MProfileUser();

            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*************/

                profile.ProfileId = request.ProfileUser.ProfileId;
                profile.UserId    = request.ProfileUser.UserId;

                int Val = 0;

                Val = BProfile.InsertUser(profile);

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

            response.UserProfile = profile;

            return(response);
        }
Exemplo n.º 25
0
        public UserResponse GetUser([FromBody] UserRequest request)
        {
            UserResponse response = new UserResponse();
            MUser        user     = new MUser();

            BaseRequest baseRequest = new BaseRequest();

            baseRequest.Session = request.Session;

            /*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*************/

            user.UserId = request.User.UserId;

            int Val = 0;

            user = BUser.Sel(user, ref Val);

            if (Val.Equals(0))
            {
                response.Code    = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = Messages.Success;
            }
            else if (Val.Equals(2))
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = String.Format(Messages.ErrorObtainingReults, "User");
            }
            else if (Val.Equals(1))
            {
                response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = String.Format(Messages.NotReults, "User");
            }

            response.User = user;

            return(response);
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
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);
        }