/// <summary> /// Delete Business Partner individual /// </summary> /// <param name="businessPartnerIndividual"></param> public void DeleteBusinessPartnerIndividual(BusinessPartnerIndividual businessPartnerIndividual) { BusinessPartnerIndividual businessPartnerIndividualDbVersion = FindBusinessPartnerIndividual((int)businessPartnerIndividual.BusinessPartnerId); if (businessPartnerIndividualDbVersion == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Business Partner with Id {0} not found!", businessPartnerIndividual.BusinessPartnerId)); } businessPartnerIndividualRepository.Delete(businessPartnerIndividualDbVersion); businessPartnerIndividualRepository.SaveChanges(); }
/// <summary> /// Create web model from entity /// </summary> public static ApiModel.BusinessPartnerIndividual CreateFrom(this BusinessPartnerIndividual source) { if (source == null) { return(null); } return(new ApiModel.BusinessPartnerIndividual { BusinessPartnerId = source.BusinessPartnerId, FirstName = source.FirstName, LastName = source.LastName, GenderStatus = source.GenderStatus, Initials = source.Initials, IqamaExpiryDate = source.IqamaExpiryDate, DateOfBirth = source.DateOfBirth, CompanyAddress = source.CompanyAddress, CompanyPhone = source.CompanyPhone, BusinessPartnerCompanyId = source.BusinessPartnerCompanyId, CompanyName = source.CompanyName, TaxRegisterationCode = source.TaxRegisterationCode, TaxNumber = source.TaxNumber, PassportNumber = source.PassportNumber, PassportExpiryDate = source.PassportExpiryDate, PassportCountryId = source.PassportCountryId, OccupationTypeId = source.OccupationTypeId, NicNumber = source.NicNumber, NicExpiryDate = source.LiscenseExpiryDate, LiscenseNumber = source.LiscenseNumber, LiscenseExpiryDate = source.LiscenseExpiryDate, MiddleName = source.MiddleName, MaritalStatusCode = source.MaritalStatusCode, IsCompanyExternal = source.IsCompanyExternal, IqamaNo = source.IqamaNo }); }
///// <summary> ///// Add business partner ///// </summary> ///// <param name="businessPartner"></param> ///// <returns></returns> //public bool AddBusinessPartner(BusinessPartner businessPartner) //{ // if (ValidateBusinessPartner(businessPartner)) // { // businessPartner.BusinessPartnerCode = "BP-Screen"; // businessPartner.UserDomainKey = businessPartnerRepository.UserDomainKey; // businessPartner.IsActive = true; // businessPartner.IsDeleted = false; // businessPartner.IsPrivate = false; // businessPartner.IsReadOnly = false; // businessPartner.RecCreatedDt = DateTime.Now; // businessPartner.RecLastUpdatedDt = DateTime.Now; // businessPartner.RecCreatedBy = businessPartnerRepository.LoggedInUserIdentity; // businessPartner.RecLastUpdatedBy = businessPartnerRepository.LoggedInUserIdentity; // businessPartner.RowVersion = 0; // businessPartnerIndividualRepository.Add(businessPartner); // businessPartnerIndividualRepository.SaveChanges(); // return true; // } // return false; //} /// <summary> /// Validate Business Partner /// </summary> /// <param name="businessPartner"></param> /// <returns></returns> private bool ValidateBusinessPartner(BusinessPartnerIndividual businessPartnerIndividual) { BusinessPartnerIndividual businessPartnerIndividualDbVersion = businessPartnerIndividualRepository.GetBusinessPartnerIndividualByName(businessPartnerIndividual.FirstName, (int)businessPartnerIndividual.BusinessPartnerId); return(businessPartnerIndividualDbVersion == null); }