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