Example #1
0
        //for insert in the address
        public static void InsertInAddress(AddressData objAddress)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Addressbook addressbook       = new Addressbook();

            if (dc.States.First(e1 => e1.PKStateId == objAddress.FKStateId) != null && dc.UserDetails.First(e1 => e1.PKUserId == objAddress.FKUserId) != null)
            {
                addressbook.FKStateId = objAddress.FKStateId;
                addressbook.FKUserId  = objAddress.FKUserId;
                addressbook.FirstName = objAddress.FirstName;
                addressbook.LastName  = objAddress.LastName;
                addressbook.EmailId   = objAddress.EmailId;
                addressbook.PhoneNo   = objAddress.PhoneNo;
                addressbook.Address1  = objAddress.Address1;
                addressbook.Address2  = objAddress.Address2;
                addressbook.Street    = objAddress.Street;
                addressbook.City      = objAddress.City;
                addressbook.ZipCode   = objAddress.ZipCode;
                addressbook.IsActive  = objAddress.IsActive;
                dc.Addressbooks.InsertOnSubmit(addressbook);
                dc.SubmitChanges();
            }
            else
            {
                throw new Exception("Plese Enter the valid Statename and UserName");
            }
        }
Example #2
0
        public static void UpdateInAddress(AddressData objAddress)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Addressbook addressbook       = dc.Addressbooks.First(e1 => e1.PKAddressId == objAddress.PKAddressId);

            if (dc.States.First(e1 => e1.PKStateId == objAddress.FKStateId) != null && dc.UserDetails.First(e1 => e1.PKUserId == objAddress.FKUserId) != null)
            {
                addressbook.FKStateId = objAddress.FKStateId;
                addressbook.FKUserId  = objAddress.FKUserId;
                addressbook.FirstName = objAddress.FirstName;
                addressbook.LastName  = objAddress.LastName;
                addressbook.EmailId   = objAddress.EmailId;
                addressbook.PhoneNo   = objAddress.PhoneNo;
                addressbook.Address1  = objAddress.Address1;
                addressbook.Address2  = objAddress.Address2;
                addressbook.Street    = objAddress.Street;
                addressbook.City      = objAddress.City;
                addressbook.ZipCode   = objAddress.ZipCode;
                addressbook.IsActive  = objAddress.IsActive;
                dc.SubmitChanges();
            }
            else
            {
                throw new Exception("Please check the details ");
            }
        }
Example #3
0
        //for delete the state
        public static void DeleteInSatte(int stateId)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            State state = dc.States.First(e1 => e1.PKStateId == stateId);

            dc.States.DeleteOnSubmit(state);
            dc.SubmitChanges();
        }
        //delete from the user detail
        public static void DeleteInUserDetail(int userId)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            UserDetail us = dc.UserDetails.First(e1 => e1.PKUserId == userId);

            dc.UserDetails.DeleteOnSubmit(us);
            dc.SubmitChanges();
        }
Example #5
0
        //for deleting
        public static void DeleteInAddress(int addreessId)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Addressbook addressbook       = dc.Addressbooks.First(e1 => e1.PKAddressId == addreessId);

            dc.Addressbooks.DeleteOnSubmit(addressbook);
            dc.SubmitChanges();
        }
Example #6
0
        //for deleting
        public static void DeleteCountry(int countryId)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Country country = dc.Countries.First(e1 => e1.PKCountryId == countryId);

            dc.Countries.DeleteOnSubmit(country);
            dc.SubmitChanges();
        }
Example #7
0
        //for inserting
        public static void InsertNewCountry(Countrydata objcountryData)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Country country = new Country();

            country.CountryName  = objcountryData.CountryName;
            country.ZipCodeStart = objcountryData.ZipCodeStart;
            country.ZipCodeEnd   = objcountryData.ZipCodeEnd;
            country.IsActive     = objcountryData.IsActive;
            dc.Countries.InsertOnSubmit(country);
            dc.SubmitChanges();
        }
Example #8
0
        //for updating
        public static void UpdateCountry(Countrydata objCountryData)
        {
            int countryId = objCountryData.PKCountry;
            Contact_managerDataContext dc = new Contact_managerDataContext();
            Country country = dc.Countries.First(e1 => e1.PKCountryId == countryId);

            country.CountryName  = objCountryData.CountryName;
            country.ZipCodeStart = objCountryData.ZipCodeStart;
            country.ZipCodeEnd   = objCountryData.ZipCodeEnd;
            country.IsActive     = objCountryData.IsActive;
            //dc.Countries.InsertOnSubmit(country);
            dc.SubmitChanges();
        }
        //update the user details
        public static void UpdateInUserDetail(UserData objUserData)
        {
            int userId = objUserData.UserId;
            Contact_managerDataContext dc = new Contact_managerDataContext();
            UserDetail us = dc.UserDetails.First(e1 => e1.PKUserId == userId);

            us.UserName  = objUserData.UserName;
            us.Password  = objUserData.Password;
            us.FirstName = objUserData.FirstName;
            us.LastName  = objUserData.LastName;
            us.EmailId   = objUserData.EmailId;
            us.PhoneNo   = objUserData.PhoneNo;
            us.IsActive  = objUserData.IsActive;
            dc.SubmitChanges();
        }
        //to get insert data
        public static void InsertInUserDetail(UserData objUserData)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            UserDetail us = new UserDetail();

            us.UserName  = objUserData.UserName;
            us.Password  = objUserData.Password;
            us.FirstName = objUserData.FirstName;
            us.LastName  = objUserData.LastName;
            us.EmailId   = objUserData.EmailId;
            us.PhoneNo   = objUserData.PhoneNo;
            us.IsActive  = objUserData.IsActive;
            dc.UserDetails.InsertOnSubmit(us);
            dc.SubmitChanges();
        }
Example #11
0
        //Update the value in state table
        public static void UpdateInState(StateData objStateDate)
        {
            Contact_managerDataContext dc = new Contact_managerDataContext();
            State state = dc.States.First(e1 => e1.PKStateId == objStateDate.StateId);

            if (dc.Countries.First(e1 => e1.PKCountryId == objStateDate.FKCountryId) != null)
            {
                state.FKCountryId = objStateDate.FKCountryId;
                state.StateName   = objStateDate.StateName;
                state.IsActive    = objStateDate.IsActive;
                dc.SubmitChanges();
            }
            else
            {
                throw new ApplicationException("please provide a valid country");
            }
        }
Example #12
0
        public static void InsertInState(StateData objStateData)
        {
            int fKCountryId = objStateData.FKCountryId;
            Contact_managerDataContext dc = new Contact_managerDataContext();
            State state = new State();

            if (dc.Countries.First(e1 => e1.PKCountryId == fKCountryId) != null)
            {
                state.FKCountryId = fKCountryId;
                state.StateName   = objStateData.StateName;
                state.IsActive    = objStateData.IsActive;
                dc.States.InsertOnSubmit(state);
                dc.SubmitChanges();
            }
            else
            {
                throw new ApplicationException("PLease inter the valid countryid");
            }
        }