/// <summary> /// Returns true if Individual instances are equal /// </summary> /// <param name="other">Instance of Individual to be compared</param> /// <returns>Boolean</returns> public bool Equals(Individual other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( FamilyName == other.FamilyName || FamilyName != null && FamilyName.Equals(other.FamilyName) ) && ( MiddleName == other.MiddleName || MiddleName != null && MiddleName.Equals(other.MiddleName) ) && ( Href == other.Href || Href != null && Href.Equals(other.Href) ) && ( Gender == other.Gender || Gender != null && Gender.Equals(other.Gender) ) && ( PlaceOfBirth == other.PlaceOfBirth || PlaceOfBirth != null && PlaceOfBirth.Equals(other.PlaceOfBirth) ) && ( CountryOfBirth == other.CountryOfBirth || CountryOfBirth != null && CountryOfBirth.Equals(other.CountryOfBirth) ) && ( Nationality == other.Nationality || Nationality != null && Nationality.Equals(other.Nationality) ) && ( MaritalStatus == other.MaritalStatus || MaritalStatus != null && MaritalStatus.Equals(other.MaritalStatus) ) && ( BirthDate == other.BirthDate || BirthDate != null && BirthDate.Equals(other.BirthDate) ) && ( FullName == other.FullName || FullName != null && FullName.Equals(other.FullName) ) && ( FormattedName == other.FormattedName || FormattedName != null && FormattedName.Equals(other.FormattedName) ) && ( Location == other.Location || Location != null && Location.Equals(other.Location) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Title != null) { hashCode = hashCode * 59 + Title.GetHashCode(); } if (GivenName != null) { hashCode = hashCode * 59 + GivenName.GetHashCode(); } if (FamilyName != null) { hashCode = hashCode * 59 + FamilyName.GetHashCode(); } if (MiddleName != null) { hashCode = hashCode * 59 + MiddleName.GetHashCode(); } if (Href != null) { hashCode = hashCode * 59 + Href.GetHashCode(); } if (Gender != null) { hashCode = hashCode * 59 + Gender.GetHashCode(); } if (PlaceOfBirth != null) { hashCode = hashCode * 59 + PlaceOfBirth.GetHashCode(); } if (CountryOfBirth != null) { hashCode = hashCode * 59 + CountryOfBirth.GetHashCode(); } if (Nationality != null) { hashCode = hashCode * 59 + Nationality.GetHashCode(); } if (MaritalStatus != null) { hashCode = hashCode * 59 + MaritalStatus.GetHashCode(); } if (BirthDate != null) { hashCode = hashCode * 59 + BirthDate.GetHashCode(); } if (FullName != null) { hashCode = hashCode * 59 + FullName.GetHashCode(); } if (FormattedName != null) { hashCode = hashCode * 59 + FormattedName.GetHashCode(); } if (Location != null) { hashCode = hashCode * 59 + Location.GetHashCode(); } if (Status != null) { hashCode = hashCode * 59 + Status.GetHashCode(); } return(hashCode); } }
public async Task <IHttpActionResult> Register(UserRegistrationModel model) { try { if (!ModelState.IsValid) { var modelErrors = new List <string>(); foreach (var modelState in ModelState.Values) { foreach (var modelError in modelState.Errors) { modelErrors.Add(modelError.ErrorMessage); } } return(Content(HttpStatusCode.BadRequest, modelErrors[0].ToString())); } if (await _bucket.ExistsAsync(model.Email)) { return(Content(HttpStatusCode.Conflict, new Error($"Email '{model.Email}' already exists"))); } if (await _bucket.ExistsAsync(model.EmiratId)) { return(Content(HttpStatusCode.Conflict, new Error($"EmiratId '{model.EmiratId}' already exists"))); } if (await _bucket.ExistsAsync(model.Phone)) { return(Content(HttpStatusCode.Conflict, new Error($"Phone '{model.EmiratId}' already exists"))); } Body body = new Body(); body.UniFiedNumber = model.Body.UniFiedNumber; body.PlaceOfBirthAr = model.Body.PlaceOfBirthAr; body.PlaceOfBirthEn = model.Body.PlaceOfBirthEn; body.DateOfBirth = model.Body.DateOfBirth; if (model.Body.IdentityCard != null) { IdentityCard identityCard = new IdentityCard(); identityCard.Number = model.Body.IdentityCard.Number; identityCard.IssueDate = DateTime.Today; identityCard.ExpiryDate = DateTime.Today; body.IdentityCard = identityCard; } if (model.Body.Nationality != null) { Nationality nationality = new Nationality(); nationality.ArDesc = model.Body.Nationality.ArDesc; nationality.EnDesc = model.Body.Nationality.EnDesc; body.Nationality = nationality; } if (model.Body.PersonName != null) { PersonName personName = new PersonName(); personName.FullArabicName = model.Body.PersonName.FirstNameArabic; personName.FirstNameArabic = model.Body.PersonName.FirstNameArabic; personName.SecondNameArabic = model.Body.PersonName.SecondNameArabic; personName.ThirdNameArabic = model.Body.PersonName.ThirdNameArabic; personName.FourthNameArabic = model.Body.PersonName.FourthNameArabic; personName.FamilyNameArabic = model.Body.PersonName.FamilyNameArabic; personName.FullEnglishName = model.Body.PersonName.FullEnglishName; personName.FirstNameEnglish = model.Body.PersonName.FirstNameEnglish; personName.SecondNameEnglish = model.Body.PersonName.SecondNameEnglish; personName.ThirdNameEnglish = model.Body.PersonName.ThirdNameEnglish; personName.FourthNameEnglish = model.Body.PersonName.FourthNameEnglish; personName.FamilyNameEnglish = model.Body.PersonName.FamilyNameEnglish; Tribe tribe = new Tribe(); tribe.ArDesc = model.Body.PersonName.Tribe.ArDesc; tribe.EnDesc = model.Body.PersonName.Tribe.EnDesc; personName.Tribe = tribe; body.PersonName = personName; } if (model.Body.Gender != null) { Gender gender = new Gender(); gender.ArDesc = model.Body.Gender.ArDesc; gender.EnDesc = model.Body.Gender.EnDesc; body.Gender = gender; } if (model.Body.CountryOfBirth != null) { CountryOfBirth countryOfBirth = new CountryOfBirth(); countryOfBirth.ArDesc = model.Body.CountryOfBirth.ArDesc; countryOfBirth.EnDesc = model.Body.CountryOfBirth.EnDesc; body.CountryOfBirth = countryOfBirth; } if (model.Body.EmirateOfBirth != null) { EmirateOfBirth emirateOfBirth = new EmirateOfBirth(); emirateOfBirth.ArDesc = model.Body.EmirateOfBirth.ArDesc; emirateOfBirth.EnDesc = model.Body.EmirateOfBirth.EnDesc; body.EmirateOfBirth = emirateOfBirth; } if (model.Body.EmirateOfBirth != null) { CityOfBirth cityOfBirth = new CityOfBirth(); cityOfBirth.ArDesc = model.Body.CityOfBirth.ArDesc; cityOfBirth.EnDesc = model.Body.CityOfBirth.EnDesc; body.CityOfBirth = cityOfBirth; } if (model.Body.MaritalStatus != null) { MaritalStatus maritalStatus = new MaritalStatus(); maritalStatus.EnDesc = model.Body.MaritalStatus.EnDesc; maritalStatus.ArDesc = model.Body.MaritalStatus.ArDesc; body.MaritalStatus = maritalStatus; } if (model.Body.Address != null) { Address address = new Address(); address.AddressLine1 = model.Body.Address.AddressLine1; address.AddressLine1 = model.Body.Address.AddressLine1; address.City = model.Body.Address.City; address.State = model.Body.Address.State; address.Country = model.Body.Address.Country; body.Address = address; } if (model.Body.Religion != null) { Religion religion = new Religion(); religion.ArDesc = model.Body.Religion.ArDesc; religion.EnDesc = model.Body.Religion.EnDesc; body.Religion = religion; } TrnHeader trnHeader = new TrnHeader(); if (model.Body.Religion != null) { trnHeader.ServiceProviderEntity = "APTC"; } var eotp = GenerateOtp(); var motp = GenerateOtp(); sendEmail.SendOtpViaEmail(model.Email, model.Body.PersonName.FirstNameEnglish, eotp); //SendOtpViaMobile(model.Phone, motp); string password = Guid.NewGuid().ToString("d").Substring(1, 4); var userDoc = new Document <UserRegistrationModel>() { Id = "Customer_" + model.EmiratId, Content = new UserRegistrationModel { IsVerifiedOtp = false, EmailOtp = eotp, MobileOtp = motp, Language = model.Language, Email = model.Email, Password = password, Phone = model.Phone, OtherPhone = model.OtherPhone, EmiratId = model.EmiratId, PassPort = model.PassPort, Body = body, TrnHeader = trnHeader }, }; var result = await _bucket.InsertAsync(userDoc); if (!result.Success) { return(Content(HttpStatusCode.InternalServerError, new Error(result.Message))); } else { //sendEmail.SendUserIdAndPassword(model.Email, password); var userDocLogin = new Document <Login>() { Id = "Login_" + model.Email, Content = new Login { Created_by = model.Email, Created_on = DateTime.Now.ToString(), UserId = model.Email, Password = password, Pre_language = model.Language, Status = "A", Type = "CAST", Role = "User", }, }; IBucket _bucketLogin = ClusterHelper.GetBucket(ConfigurationManager.AppSettings.Get("CouchbaseLoginBucket")); var resultLogin = await _bucketLogin.InsertAsync(userDocLogin); return(Content(HttpStatusCode.Accepted, result.Document.Id)); } } catch (Exception ex) { return(Content(HttpStatusCode.Forbidden, ex.StackTrace)); } }