Example #1
0
        /// <summary>
        /// Updates the db instance with user data for add/update operation
        /// </summary>
        private void SetUpdateedProperties(WorkLocation dbvWorkLocation, WorkLocation upDatedWorkLocation, String operation)
        {
            if (operation.Equals("update"))
            {
                dbvWorkLocation.RecLastUpdatedBy        = workLocationRepository.LoggedInUserIdentity;
                dbvWorkLocation.RecLastUpdatedDt        = DateTime.Now;
                dbvWorkLocation.WorkLocationCode        = upDatedWorkLocation.WorkLocationCode;
                dbvWorkLocation.WorkLocationName        = upDatedWorkLocation.WorkLocationName;
                dbvWorkLocation.WorkLocationDescription = upDatedWorkLocation.WorkLocationDescription;

                dbvWorkLocation.Address.ContactPerson = upDatedWorkLocation.Address.ContactPerson;
                dbvWorkLocation.Address.StreetAddress = upDatedWorkLocation.Address.StreetAddress;

                dbvWorkLocation.Address.EmailAddress = upDatedWorkLocation.Address.EmailAddress;
                dbvWorkLocation.Address.WebPage      = upDatedWorkLocation.Address.WebPage;
                dbvWorkLocation.Address.ZipCode      = upDatedWorkLocation.Address.ZipCode;

                dbvWorkLocation.Address.POBox     = upDatedWorkLocation.Address.POBox;
                dbvWorkLocation.Address.CountryId = upDatedWorkLocation.Address.CountryId;
                dbvWorkLocation.Address.RegionId  = upDatedWorkLocation.Address.RegionId;

                dbvWorkLocation.Address.SubRegionId = upDatedWorkLocation.Address.SubRegionId;
                dbvWorkLocation.Address.CityId      = upDatedWorkLocation.Address.CityId;
                dbvWorkLocation.Address.AreaId      = upDatedWorkLocation.Address.AreaId;
            }
            else
            {
                dbvWorkLocation.Address = new Address
                {
                    ContactPerson    = upDatedWorkLocation.Address.ContactPerson,
                    StreetAddress    = upDatedWorkLocation.Address.StreetAddress,
                    EmailAddress     = upDatedWorkLocation.Address.EmailAddress,
                    WebPage          = upDatedWorkLocation.Address.WebPage,
                    ZipCode          = upDatedWorkLocation.Address.ZipCode,
                    POBox            = upDatedWorkLocation.Address.POBox,
                    AddressTypeId    = addressTypeRepository.GetAddressTypeIdByAddressTypeKey(1),
                    CountryId        = upDatedWorkLocation.Address.CountryId,
                    RegionId         = upDatedWorkLocation.Address.RegionId,
                    SubRegionId      = upDatedWorkLocation.Address.SubRegionId,
                    CityId           = upDatedWorkLocation.Address.CityId,
                    AreaId           = upDatedWorkLocation.Address.AreaId,
                    RecCreatedBy     = workLocationRepository.LoggedInUserIdentity,
                    RecCreatedDt     = DateTime.Now,
                    RecLastUpdatedDt = DateTime.Now,
                    RecLastUpdatedBy = workLocationRepository.LoggedInUserIdentity,
                };
                dbvWorkLocation.RecCreatedBy = dbvWorkLocation.RecLastUpdatedBy = workLocationRepository.LoggedInUserIdentity;

                dbvWorkLocation.RecCreatedDt            = DateTime.Now;
                dbvWorkLocation.RecLastUpdatedDt        = DateTime.Now;
                dbvWorkLocation.UserDomainKey           = workLocationRepository.UserDomainKey;
                dbvWorkLocation.CompanyId               = upDatedWorkLocation.CompanyId;
                dbvWorkLocation.WorkLocationCode        = upDatedWorkLocation.WorkLocationCode;
                dbvWorkLocation.WorkLocationName        = upDatedWorkLocation.WorkLocationName;
                dbvWorkLocation.WorkLocationDescription = upDatedWorkLocation.WorkLocationDescription;
            }
        }