Exemple #1
0
        //public Party SaveParty(string licenseNo, string name,string state,string loginUser,string imageRefId) {
        public Party SaveParty(Party party, AddressBook address)
        {
            Party entity = null;

            // Save Party
            if (party != null)
            {
                PartyLibrary partyLib = new PartyLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                entity = partyLib.GetByID(party.ID.ToString());
                if (entity == null || entity.ID <= 0)
                {
                    entity = new Party();
                }
                entity.License_No          = party.License_No;
                entity.Party_Name          = party.Party_Name;
                entity.Party_Short_Name    = party.Party_Short_Name;
                entity.State               = party.State;
                entity.Created_By          = party.Created_By;
                entity.Created_Date        = DateTime.Now;
                entity.Active_Ind          = true;
                entity.IsActive            = true;
                entity.Updated_By          = party.Updated_By;
                entity.Last_Updated_Date   = DateTime.Now;
                entity.Party_Type          = "Individual";
                entity.LicenseImageRefId   = party.LicenseImageRefId;
                entity.Party_DOB           = party.Party_DOB;
                entity.ACLicense_ID        = party.ACLicense_ID;
                entity.ThumbImage1RefId    = party.ThumbImage1RefId;
                entity.ThumbImage2RefId    = party.ThumbImage2RefId;
                entity.PhotoRefId          = party.PhotoRefId;
                entity.SignatureImageRefId = party.SignatureImageRefId;
                entity.VehicleImageRegId   = party.VehicleImageRegId;
                entity.CashCardImageRefId  = party.CashCardImageRefId;

                if (entity == null || entity.ID <= 0)
                {
                    entity = partyLib.Add(entity);
                }
                else
                {
                    entity = partyLib.Modify(entity);
                }


                // Save Address
                if (address != null)
                {
                    AddressBookLibrary addressLib  = new AddressBookLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                    AddressBook        addressBook = addressLib.GetPrimaryAddressesByPartyId(entity.ID);
                    if (addressBook == null || addressBook.ID <= 0)
                    {
                        addressBook = new AddressBook();
                    }

                    addressBook.Party        = entity;
                    addressBook.Address1     = address.Address1;
                    addressBook.City         = address.City;
                    addressBook.State        = party.State;
                    addressBook.Zip_Code     = address.Zip_Code;
                    addressBook.Country      = address.Country;
                    addressBook.Primary_Flag = true;
                    addressBook.Address_Type = address.Address_Type;

                    addressBook.Created_By        = party.Created_By;
                    addressBook.Created_Date      = DateTime.Now;
                    addressBook.Active_Ind        = true;
                    addressBook.Updated_By        = party.Updated_By;
                    addressBook.Last_Updated_Date = DateTime.Now;

                    if (addressBook == null || addressBook.ID <= 0)
                    {
                        addressLib.Add(addressBook);
                    }
                    else
                    {
                        addressLib.Modify(addressBook);
                    }
                }
            }
            return(entity);
        }
        public AddressBook GetAddressByPartyId(int partyId)
        {
            AddressBookLibrary lib = new AddressBookLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());

            return(lib.GetPrimaryAddressesByPartyId(partyId));
        }