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); }
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); }