Example #1
0
        public static ReturnObject EditPrimary(HttpContext context, long id, string street_1, string street_2, string city, string state, string zip)
        {
            Data.Address item = new Data.Address(id);

            item.Street1 = street_1;
            item.Street2 = street_2;
            item.City = city;
            item.State = state;
            item.Zip = zip;
            item.Save();

            return new ReturnObject()
            {
                Result = item,
                Growl = new ReturnGrowlObject()
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject()
                    {
                        text = "You have successfully updated your primary address.",
                        title = "Address Updated"
                    }
                }
            };
        }
Example #2
0
        public FakeProductsRepo()
        {
            Data.Address address = new Data.Address()
            {
                Country = "Belgium",
                Id      = 1,
                Number  = 77,
                Street  = "Ter Platen",
                Zipcode = "9000"
            };

            Data.Company company = new Data.Company()
            {
                Address     = address,
                Name        = "My Company",
                Id          = 1,
                PhoneNumber = 0483663598,
                VAT         = "BE12345678",
                Website     = "MyCompany.com"
            };

            Data.Category category = new Data.Category()
            {
                Company = company,
                Id      = 1,
                Name    = "Drank"
            };

            Data.SubCategory subCategory = new Data.SubCategory()
            {
                Category = category,
                Id       = 1,
                Name     = "Bier"
            };

            _products = new List <Data.Product>();
            _products.Add(new Data.Product()
            {
                SubCategory = subCategory,
                Id          = 1,
                Name        = "Westmalle",
                Price       = 4.5
            });
            _products.Add(new Data.Product()
            {
                SubCategory = subCategory,
                Id          = 2,
                Name        = "Westvleteren",
                Price       = 10
            });
            _products.Add(new Data.Product()
            {
                SubCategory = subCategory,
                Id          = 3,
                Name        = "Jupiler",
                Price       = 2
            });
        }
 public Address()
     : base()
 {
     _address= new Data.Address(ModuleSettings);
     Phone = "";
     PostalAddress = "";
     Postcode = "";
     EMail = "";
     Mobile = "";
     Phone = "";
     Notes = "";
 }
        public NetCoreWebAPIs.Core.Models.Address SaveAddress(NetCoreWebAPIs.Core.Models.Address address)
        {
            //TODO fix this manual mess.
            var entity = new Data.Address
            {
                AddressId  = address.AddressId,
                CustomerId = address.CustomerId,
                Street     = address.Street,
                City       = address.City,
                State      = address.State,
                Zip        = address.Zip
            };

            addressRepository.Save(entity);
            address.AddressId = entity.AddressId;
            return(address);
        }
Example #5
0
        public static void CreateNewAddress(Dto.Address address)
        {
            using (var db = new Data.DrinkzAppBDDataContext())
            {
                var dbAddress = new Data.Address()
                {

                    FK_PROFILE = address.FK_PROFILE,
                    STATE = address.STATE,
                    STREET = address.STREET,
                    ZIP_CODE = address.ZIP_CODE,

                };

                db.Addresses.InsertOnSubmit(dbAddress);

                db.SubmitChanges();
            }
        }
        public Address(int addressId)
            : base()
        {
            _address = new Data.Address(ModuleSettings);

            ID = addressId;
            try
            {
                var ds = _address.GetAddress(ID);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    LoadFromDb(ds.Tables[0].Rows[0]);
                }

            }
            catch (Exception e )
            {
                AppException.LogEvent("Address: " + e.Message);
            }
        }
Example #7
0
        public FakeUserRepo()
        {
            _address = new Data.Address()
            {
                ID      = 1,
                Country = "Belgium",
                Zipcode = "9300",
                Street  = "Vlaanderenstraat",
                Number  = 20
            };

            _user = new Data.User()
            {
                ID          = 1,
                FirstName   = "Tibo",
                LastName    = "Van De Sijpe",
                Address     = _address,
                Email       = "*****@*****.**",
                Password    = "******",
                PhoneNumber = 0483663598,
                Role        = Data.Roles.MANAGER
            };
        }
Example #8
0
        public static GymDataResponse gymRegisterImplementation(RegisterGymRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.gymName))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a gym name"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.gymPhone))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a gym phone number"
                });
            }

            else if (String.IsNullOrWhiteSpace(request.contactName))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a contact name"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.contactEmail))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter an email"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.contactPhone))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a phone number"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.website))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a website"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.address))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a street"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.city))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a city"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.state))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a state or province"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.zip))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a zip code"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.priceTier))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please select one given of the price tiers"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.password) || request.password.Length < 6)
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a password greater than 5 characters"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.website))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a website"
                });
            }
            if (MembershipHelper.emailAlreadyExists(request.contactEmail, Constants.GymRole))
            {
                return(new GymDataResponse {
                    success = false, status = 10, message = "Email already taken."
                });
            }


            var newGymGuid = MembershipHelper.createMembership(request.contactEmail, request.password, Constants.GymRole);

            using (var db = new UniversalGymEntities())
            {
                var state = db.TypeStates.FirstOrDefault(f => f.StateAbbreviation.ToLower() == request.state.ToLower()) ??
                            db.TypeStates.First(f => f.StateAbbreviation == "00");

                var address = new Data.Address()
                {
                    StreetLine1 = request.address,
                    City        = request.city,
                    Zip         = request.zip,
                    TypeStateId = state.TypeStateId
                };
                db.Addresses.Add(address);
                var publicContactInfo = new Data.ContactInfo
                {
                    AddressId = address.AddressId,
                    Phone     = request.gymPhone,
                };
                db.ContactInfoes.Add(publicContactInfo);
                db.SaveChanges();
                var ownerContactInfo = new Data.ContactInfo
                {
                    Email = request.contactEmail,
                    Phone = request.contactPhone,
                };
                db.ContactInfoes.Add(ownerContactInfo);
                db.SaveChanges();

                var gym = new Data.Gym
                {
                    CreditDollarValue = Constants.returnGymPay(request.priceTier),
                    PriceToCharge     = Constants.returnGymPrice(request.priceTier),
                    GymName           = request.gymName,
                    IsApproved        = false,
                    OwnerName         = request.contactName,
                    Url = request.website.Contains("://") ? request.website : "http://" + request.website,
                    PublicContactInfoId = publicContactInfo.ContactInfoId,
                    OwnerContactInfoId  = ownerContactInfo.ContactInfoId,
                    GymInfo             = "",
                    GymGuid             = newGymGuid,
                    ApplicationDate     = DateTime.UtcNow,
                    IsActive            = true,
                };


                db.Gyms.Add(gym);
                var target   = request.address + " " + request.state + " " + request.zip;
                var geocoded = Geocoder.GeoCodeAddress(target);
                if (geocoded != null)
                {
                    gym.Position = System.Data.Entity.Spatial.DbGeography.FromText(geocoded.GetPointString());
                    db.SaveChanges();

                    var newgymBody = "Gym Registration"
                                     + Environment.NewLine
                                     + "Gym Name: "
                                     + gym.GymName
                                     + Environment.NewLine
                                     + "Location: "
                                     + request.address
                                     + Environment.NewLine
                                     + "City: "
                                     + request.city
                                     + Environment.NewLine
                                     + "State: "
                                     + request.state
                                     + Environment.NewLine
                                     + "Zip Code: "
                                     + request.zip
                                     + Environment.NewLine
                                     + "Gym Phone"
                                     + request.gymPhone
                                     + Environment.NewLine
                                     + "Contact Name: "
                                     + request.contactName
                                     + Environment.NewLine
                                     + "Contact Email: "
                                     + request.contactEmail
                                     + Environment.NewLine
                                     + "Contact Phone: "
                                     + request.contactPhone
                                     + Environment.NewLine
                                     + "Website: "
                                     + gym.Url
                                     + Environment.NewLine;

                    SlackHelper.sendGymSignupChannel(newgymBody, geocoded.Latitude.ToString(), geocoded.Longitude.ToString());
                    // add gym id
                    var gymId = gym.GymId;
                    var link  = Constants.PedalWebUrl + "gym.html#/login";

                    EmailTemplateHelper.SendEmail("Welcome to Pedal!", request.contactEmail, link, request.gymName, "gym_signup.html");
                }
                else
                {
                    db.ContactInfoes.Remove(gym.ContactInfo);
                    db.ContactInfoes.Remove(gym.ContactInfo1);

                    var supportText = "Gym Registration - Location not found!"
                                      + Environment.NewLine
                                      + "Gym Name: "
                                      + gym.GymName
                                      + Environment.NewLine
                                      + "Location: "
                                      + request.address
                                      + Environment.NewLine
                                      + "City: "
                                      + request.city
                                      + Environment.NewLine
                                      + "State: "
                                      + request.state
                                      + Environment.NewLine
                                      + "Zip Code: "
                                      + request.zip
                                      + Environment.NewLine
                                      + "Gym Phone"
                                      + request.gymPhone
                                      + Environment.NewLine
                                      + "Contact Name: "
                                      + request.contactName
                                      + Environment.NewLine
                                      + "Contact Email: "
                                      + request.contactEmail
                                      + Environment.NewLine
                                      + "Contact Phone: "
                                      + request.contactPhone
                                      + Environment.NewLine
                                      + "Website: "
                                      + gym.Url
                                      + Environment.NewLine;

                    SlackHelper.sendSupportChannel(supportText);

                    EmailNoTemplateHelper.SendEmail("Gym Registration Problem", "*****@*****.**", supportText);

                    return(new GymDataResponse {
                        success = false, status = 200, message = "Location could not be found. The Pedal team has been notified to look into this."
                    });
                }


                return(gymDataHelper.CreateGymDataResponse(gym.GymId, true));
            }
        }
Example #9
0
        public static ReturnObject Edit(HttpContext context, long id, long parent_id, string username, string password, string email, string first_name, string last_name, string street, string city, string state, string zip, string company = null, string street_2 = null, string phone = null)
        {
            Lib.Data.DrugCompanyUser item = null;
            Lib.Data.DrugCompany parent = new Data.DrugCompany(parent_id);
            Lib.Data.UserProfile profile = null;
            Lib.Data.Contact contact = null;
            Lib.Data.Address address = null;
            Framework.Security.User user = null;

            if (id > 0)
            {
                item = new Lib.Data.DrugCompanyUser(id);
                profile = item.Profile;
                user = profile.User;
                contact = profile.PrimaryContact;
                address = profile.PrimaryAddress;
            }
            else
            {
                item = new Lib.Data.DrugCompanyUser();
                profile = new Data.UserProfile();
                profile.Created = DateTime.Now;
                contact = new Data.Contact();
                address = new Data.Address();

                string error = "";
                user = Framework.Security.Manager.CreateUser(username, password, email, out error);

                user.AddGroup(Framework.Security.Group.FindByName("users"));
                user.AddGroup(Framework.Security.Group.FindByName("drugcompany"));

                if (!string.IsNullOrEmpty(error))
                {
                    return new ReturnObject()
                    {
                        Error = true,
                        StatusCode = 200,
                        Message = error
                    };
                }
            }

            address.Street1 = street;
            address.Street2 = street_2;
            address.City = city;
            address.State = state;
            address.Zip = zip;
            address.Country = "United States";
            address.Save();

            contact.Email = email;
            contact.FirstName = first_name;
            contact.LastName = last_name;
            contact.Phone = phone;
            contact.Save();

            var ut = Lib.Data.UserType.FindByName("drug-company");

            profile.UserTypeID = ut.ID.Value;
            profile.UserID = user.ID.Value;
            profile.PrimaryAddressID = address.ID.Value;
            profile.PrimaryContactID = contact.ID.Value;
            profile.Save();

            item.ProfileID = profile.ID.Value;
            item.DrugCompanyID = parent.ID.Value;
            item.Save();

            return new ReturnObject()
            {
                Result = item,
                Redirect = new ReturnRedirectObject()
                {
                    Hash = "admin/drugs/companies/list"
                },
                Growl = new ReturnGrowlObject()
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject()
                    {
                        text = "You have successfully saved this drug company user.",
                        title = "Drug Company User Saved"
                    }
                }
            };
        }
Example #10
0
        public static ReturnObject Edit(HttpContext context, long provider_user_id, long organization_id, long facility_id, string user_type, string username, string password, string email, string first_name, string last_name, string street, string city, string state, string zip, string street_2 = null, string phone = null)
        {
            Lib.Data.Provider provider;
            Lib.Data.ProviderUser providerUser;

            UserProfile userProfile;
            Contact contact;
            Address address;

            Framework.Security.User user;

            if (provider_user_id > 0)
            {
                providerUser = new Lib.Data.ProviderUser(provider_user_id);
                provider = providerUser.Provider;
                userProfile = providerUser.Profile;
                user = userProfile.User;
                contact = userProfile.PrimaryContact;
                address = userProfile.PrimaryAddress;

                user.Username = username;
                user.Save();

                Framework.Security.Manager.SetPassword(user, password);
            }
            else
            {
                provider = new Lib.Data.Provider();
                providerUser = new Lib.Data.ProviderUser();
                userProfile = new Data.UserProfile();
                userProfile.Created = DateTime.Now;
                contact = new Data.Contact();
                address = new Data.Address();

                string error = "";
                user = Framework.Security.Manager.CreateUser(username, password, email, out error);

                user.AddGroup(Framework.Security.Group.FindByName("users"));
                user.AddGroup(Framework.Security.Group.FindByName("providers"));

                if (!string.IsNullOrEmpty(error))
                {
                    return new ReturnObject()
                    {
                        Error = true,
                        StatusCode = 200,
                        Message = error
                    };
                }
            }

            if (user_type != "technical" && user_type != "administrative")
            {
                return new ReturnObject()
                {
                    Error = true,
                    StatusCode = 200,
                    Message = "Invalid user type."
                };
            }

            address.Street1 = street;
            address.Street2 = street_2;
            address.City = city;
            address.State = state;
            address.Zip = zip;
            address.Country = "United States";
            address.Save();

            contact.Email = email;
            contact.FirstName = first_name;
            contact.LastName = last_name;
            contact.Phone = phone;
            contact.Save();

            provider.AddressID = address.ID;
            provider.PrimaryContactID = contact.ID;
            provider.Created = DateTime.Now;
            provider.FacilitySize = String.Empty;
            provider.Name = string.Empty;
            provider.Save();

            var ut = Lib.Data.UserType.FindByName("provider");

            userProfile.UserTypeID = ut.ID.Value;
            userProfile.UserID = user.ID.Value;
            userProfile.PrimaryAddressID = address.ID.Value;
            userProfile.PrimaryContactID = contact.ID.Value;
            userProfile.Save();

            providerUser.ProfileID = userProfile.ID.Value;
            providerUser.ProviderID = provider.ID.Value;
            providerUser.OrganizationID = organization_id;
            providerUser.ProviderUserType = user_type;
            providerUser.PrimaryFacilityID = facility_id;
            providerUser.Save();

            return new ReturnObject()
            {
                Result = providerUser,
                Growl = new ReturnGrowlObject()
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject()
                    {
                        text = "You have successfully saved this provider user.",
                        title = "Provider User Saved"
                    }
                }
            };
        }
 public Address(DataRow row)
     : base()
 {
     _address = new Data.Address(ModuleSettings);
     LoadFromDb(row);
 }
Example #12
0
        public static ReturnObject EditProvider(HttpContext context, long provider_user_id, string username, string password, string email, string first_name, string last_name, string street, string city, string state, string zip, string expires_on, string is_enabled, string street_2 = null, string phone = null)
        {
            IAccountService accountSvc = ObjectFactory.GetInstance<IAccountService>();

            Lib.Data.Provider provider;
            Lib.Data.ProviderUser providerUser;

            UserProfile userProfile;
            Contact contact;
            Address address;
            Account account;

            Framework.Security.User user;

            if (provider_user_id > 0)
            {
                providerUser = new Lib.Data.ProviderUser(provider_user_id);
                provider = providerUser.Provider;
                userProfile = providerUser.Profile;
                user = userProfile.User;
                contact = userProfile.PrimaryContact;
                address = userProfile.PrimaryAddress;

                account = accountSvc.GetByUserProfileId(userProfile.ID ?? 0);

                user.Username = username;
                user.Save();

                Framework.Security.Manager.SetPassword(user, password);
            }
            else
            {
                provider = new Lib.Data.Provider();
                providerUser = new Lib.Data.ProviderUser();
                userProfile = new Data.UserProfile();
                userProfile.Created = DateTime.Now;
                contact = new Data.Contact();
                address = new Data.Address();

                account = new Account
                {
                    CreatedAt = DateTime.Now
                };

                string error = "";
                user = Framework.Security.Manager.CreateUser(username, password, email, out error);

                user.AddGroup(Framework.Security.Group.FindByName("users"));
                user.AddGroup(Framework.Security.Group.FindByName("providers"));

                if (!string.IsNullOrEmpty(error))
                {
                    return new ReturnObject()
                    {
                        Error = true,
                        StatusCode = 200,
                        Message = error
                    };
                }
            }

            DateTime expiresOn;

            if(!DateTime.TryParse(expires_on, out expiresOn))
            {
                    return new ReturnObject()
                    {
                        Error = true,
                        StatusCode = 200,
                        Message = "Invalide expiration date."
                    };
            }

            address.Street1 = street;
            address.Street2 = street_2;
            address.City = city;
            address.State = state;
            address.Zip = zip;
            address.Country = "United States";
            address.Save();

            contact.Email = email;
            contact.FirstName = first_name;
            contact.LastName = last_name;
            contact.Phone = phone;
            contact.Save();

            provider.AddressID = address.ID;
            provider.PrimaryContactID = contact.ID;
            provider.Created = DateTime.Now;
            provider.FacilitySize = String.Empty;
            provider.Name = string.Empty;
            provider.Save();

            var ut = Lib.Data.UserType.FindByName("provider");

            userProfile.UserTypeID = ut.ID.Value;
            userProfile.UserID = user.ID.Value;
            userProfile.PrimaryAddressID = address.ID.Value;
            userProfile.PrimaryContactID = contact.ID.Value;
            userProfile.IsEcommerce = true;
            userProfile.Save();

            providerUser.ProfileID = userProfile.ID.Value;
            providerUser.ProviderID = provider.ID.Value;
            providerUser.OrganizationID = 0;
            providerUser.ProviderUserType = "";
            providerUser.PrimaryFacilityID = 0;
            providerUser.Save();

            account.UserProifleId = userProfile.ID ?? 0;
            account.ExpiresOn = expiresOn;
            account.IsEnabled = is_enabled == "yes";

            accountSvc.Save(account);

            return new ReturnObject()
            {
                Result = providerUser,
                Growl = new ReturnGrowlObject()
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject()
                    {
                        text = "You have successfully saved this provider user.",
                        title = "Provider User Saved"
                    }
                }
            };
        }
        protected override void OnReceive(object message)
        {
            if (message is ApplicationExecuted m)
            {
                var optionsBuilder = new DbContextOptionsBuilder <NeoNftContext>();
                optionsBuilder.UseSqlServer(connectionString);
                var db = new NeoNftContext(optionsBuilder.Options);

                foreach (var result in m.ExecutionResults)
                {
                    foreach (var notification in result.Notifications)
                    {
                        var type = notification.GetNotificationType();
                        if (type == "transfer")
                        {
                            TransferNotification transferNotification = notification.GetNotification <TransferNotification>();
                            string     receiverHexString = transferNotification.To.ToHexString();
                            string     senderHexString   = transferNotification.From.ToHexString();
                            BigInteger tokenId           = transferNotification.TokenId;


                            Data.Address receiver = db.Addresses.FirstOrDefault(c => c.AddressName == receiverHexString);
                            Data.Address sender   = db.Addresses.FirstOrDefault(c => c.AddressName == senderHexString);
                            Token        token    = db.Tokens.FirstOrDefault(c => c.TxId == tokenId.ToString());

                            var transaction = new Transaction();
                            transaction.Receiver = receiver;
                            transaction.Sender   = sender;
                            token.Address        = receiver;

                            db.Add(transaction);
                            db.Update(token);
                            db.SaveChanges();
                        }
                        else if (type == "birth")
                        {
                            MintTokenNotification mintTokenNotification = notification.GetNotification <MintTokenNotification>();
                            Token  token = new Token();
                            string owner = mintTokenNotification.Owner.ToHexString();
                            token.TxId           = mintTokenNotification.TokenId.ToString();
                            token.Nickname       = "Olaf";
                            token.Health         = mintTokenNotification.Health;
                            token.Mana           = mintTokenNotification.Mana;
                            token.Agility        = mintTokenNotification.Agility;
                            token.Stamina        = mintTokenNotification.Stamina;
                            token.CriticalStrike = mintTokenNotification.CriticalStrike;
                            token.AttackSpeed    = mintTokenNotification.AttackSpeed;
                            token.Versatility    = mintTokenNotification.Versatility;
                            token.Mastery        = mintTokenNotification.Mastery;
                            token.Level          = mintTokenNotification.Level;
                            token.Experience     = 0;
                            Data.Address address = db.Addresses.FirstOrDefault(c => owner == c.AddressName);
                            if (address == null)
                            {
                                address             = new Data.Address();
                                address.AddressName = owner;
                                db.Add(address);
                            }

                            token.Address = address;
                            db.Add(token);
                            db.SaveChanges();
                        }
                        else if (type == "auction")
                        {
                            CreateSaleAuctionNotification auctionCreatedNotification = notification.GetNotification <CreateSaleAuctionNotification>();
                            Auction auction = new Auction();
                            auction.StartDate  = DateTime.Now;
                            auction.StartPrice = (decimal)auctionCreatedNotification.BeginPrice;
                            auction.IsActive   = 1;
                            auction.EndPrice   = (decimal)auctionCreatedNotification.EndPrice;
                            auction.Duration   = (long)auctionCreatedNotification.Duration;
                            Token token = db.Tokens.FirstOrDefault(c => c.TxId == auctionCreatedNotification.TokenId.ToString());

                            if (token != null)
                            {
                                auction.Token = token;
                                db.Auctions.Add(auction);
                                db.SaveChanges();
                            }
                        }
                        else if (type == "cancelAuction")
                        {
                            CancelAuctionNotification cancelAuctionNotification = notification.GetNotification <CancelAuctionNotification>();
                            Token token = db.Tokens.Include(c => c.Address).FirstOrDefault(c => c.TxId == cancelAuctionNotification.TokenId.ToString() && c.Address.AddressName == cancelAuctionNotification.TokenOwner.ToHexString());
                            if (token != null)
                            {
                                Auction auction = db.Auctions.FirstOrDefault(c => c.Token == token);
                                auction.EndDate  = DateTime.Now;
                                auction.IsActive = 0;
                                db.Update(auction);
                                db.SaveChanges();
                            }
                        }
                        else if (type == "auctionBuy")
                        {
                            BuyOnAuctionNotification buyOnAuctionNotification = notification.GetNotification <BuyOnAuctionNotification>();

                            Auction      auction = db.Auctions.FirstOrDefault(c => c.TokenId == buyOnAuctionNotification.TokenId && c.IsActive == 1);
                            Token        token   = db.Tokens.FirstOrDefault(c => c.TxId == buyOnAuctionNotification.TokenId.ToString());
                            Data.Address address = db.Addresses.FirstOrDefault(c => c.AddressName == buyOnAuctionNotification.Buyer.ToHexString());

                            if (token != null && auction != null && address != null)
                            {
                                if (token.Address != address)
                                {
                                    auction.IsActive     = 0;
                                    auction.EndPrice     = (decimal)buyOnAuctionNotification.CurrentBuyPrice;
                                    auction.CurrentPrice = (decimal)buyOnAuctionNotification.CurrentBuyPrice;
                                    token.Address        = address;

                                    db.Update(auction);
                                    db.Update(token);
                                    db.SaveChanges();
                                }
                            }
                        }
                    }
                }

                db.Dispose();
            }
        }
 /// < summary>
 /// Mehod to Save user details 
 /// </summary>
 public static void saveUser(string address,
     string name,
     string occupation,
     int phone,
     int income,
     int limit,
     string email,
     string role = "User")
 {
     Data.Address adds = new Data.Address();
     User user = new User();
     adds.address1 = address;
     entity.AddToAddresses(adds);
     user.name = name;
     user.occupation = occupation;
     user.phone = phone;
     user.presentaddr = adds.id;
     user.permenentaddr = adds.id;
     user.income = income;
     user.limit = limit;
     user.email = email;
     user.role = role;
     entity.AddToUsers(user);
     entity.SaveChanges();
 }