public StateTypeVo update(StateTypeVo input, int? stateTypeId= null)
        {
            using (var db = new MainDb())
            {

                if (stateTypeId == null)
                    stateTypeId = input.stateTypeId;

                var res = db.stateTypes.FirstOrDefault(e => e.stateTypeId == stateTypeId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }
        public StateTypeVo insert(StateTypeVo input)
        {
            using (var db = new MainDb())
            {

                db.stateTypes.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public BusinessCategoryLookupVo insert(BusinessCategoryLookupVo input)
        {
            using (var db = new MainDb())
            {

                db.businessCategoryLookups.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public JobTypeVo insert(JobTypeVo input)
        {
            using (var db = new MainDb())
            {

                db.jobTypes.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public OptionTypeVo insert(OptionTypeVo input)
        {
            using (var db = new MainDb())
            {

                db.optionTypes.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public BusinessCategoryLookupVo update(BusinessCategoryLookupVo input, Guid? businessCategoryLookupId= null)
        {
            using (var db = new MainDb())
            {

                if (businessCategoryLookupId == null)
                    businessCategoryLookupId = input.businessCategoryLookupId;

                var res = db.businessCategoryLookups.FirstOrDefault(e => e.businessCategoryLookupId == businessCategoryLookupId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }
        public ImageVo update(ImageVo input, Guid? imageId= null)
        {
            using (var db = new MainDb())
            {

                if (imageId == null)
                    imageId = input.imageId;

                var res = db.images.FirstOrDefault(e => e.imageId == imageId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }
        public ListingVo update(ListingVo input, Guid? listingId= null)
        {
            using (var db = new MainDb())
            {

                if (listingId == null)
                    listingId = input.listingId;

                var res = db.listings.FirstOrDefault(e => e.listingId == listingId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }
        public PropertyListingTypeVo update(PropertyListingTypeVo input, int? propertyListingTypeId= null)
        {
            using (var db = new MainDb())
            {

                if (propertyListingTypeId == null)
                    propertyListingTypeId = input.propertyListingTypeId;

                var res = db.propertyListingTypes.FirstOrDefault(e => e.propertyListingTypeId == propertyListingTypeId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }
        public PropertyListingTypeVo insert(PropertyListingTypeVo input)
        {
            using (var db = new MainDb())
            {

                db.propertyListingTypes.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public BusinessServiceTypeVo insert(BusinessServiceTypeVo input)
        {
            using (var db = new MainDb())
            {

                db.businessServiceTypes.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public CountryTypeVo insert(CountryTypeVo input)
        {
            using (var db = new MainDb())
            {

                db.countryTypes.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public JobCategoryTypeVo update(JobCategoryTypeVo input, int? jobCategoryTypeId= null)
        {
            using (var db = new MainDb())
            {

                if (jobCategoryTypeId == null)
                    jobCategoryTypeId = input.jobCategoryTypeId;

                var res = db.jobCategoryTypes.FirstOrDefault(e => e.jobCategoryTypeId == jobCategoryTypeId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }
        public MemberRoleLookupVo update(MemberRoleLookupVo input, Guid? memberRoleLookupId= null)
        {
            using (var db = new MainDb())
            {

                if (memberRoleLookupId == null)
                    memberRoleLookupId = input.memberRoleLookupId;

                var res = db.memberRoleLookups.FirstOrDefault(e => e.memberRoleLookupId == memberRoleLookupId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }
        public ImageVo insert(ImageVo input)
        {
            using (var db = new MainDb())
            {

                db.images.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public MemberRoleLookupVo insert(MemberRoleLookupVo input)
        {
            using (var db = new MainDb())
            {

                db.memberRoleLookups.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public CarModelTypeVo insert(CarModelTypeVo input)
        {
            using (var db = new MainDb())
            {

                db.carModelTypes.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public ListingVo insert(ListingVo input)
        {
            using (var db = new MainDb())
            {

                db.listings.Add(input);
                db.SaveChanges();

                return input;
            }
        }
        public CarVo update(CarVo input, Guid? carId= null)
        {
            using (var db = new MainDb())
            {

                if (carId == null)
                    carId = input.carId;

                var res = db.cars.FirstOrDefault(e => e.carId == carId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }