示例#1
0
        /// <summary>
        /// DeleteUser
        /// </summary>
        /// <param name="mobile"></param>
        public int DeleteUser(string mobile)
        {
            DataAccessDataContext ctx = new DataAccessDataContext();
            var userList = ctx.Users.ToList();

            foreach (var user in userList)
            {
                ctx.Users.DeleteOnSubmit(user);
            }

            var addressList = ctx.Addresses.ToList();

            foreach (var address in addressList)
            {
                ctx.Addresses.DeleteOnSubmit(address);
            }

            var authList = ctx.Auths.ToList();

            foreach (var auth in authList)
            {
                ctx.Auths.DeleteOnSubmit(auth);
            }

            ctx.SubmitChanges();

            return(204);
        }
示例#2
0
        /// <summary>
        /// RegisterKey
        /// </summary>
        /// <param name="key"></param>
        /// <param name="mobileNumber"></param>
        /// <returns></returns>
        public int RegisterUserKey(string key, string mobile)
        {
            DataAccessDataContext ctx = new DataAccessDataContext();
            var user       = ctx.Users.Where(@w => @w.Mobile == mobile).First();
            var authSingle = ctx.Auths.Where(@w => @w.Id == user.AuthId).First();

            authSingle.Key           = key;
            authSingle.ApplicationId = key.Replace(user.Name, "").Replace(mobile, "");
            ctx.SubmitChanges();

            return(203);
        }
示例#3
0
        /// <summary>
        /// InsertAddressMetaData
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        private static Guid InsertAddressMetaData(DataAccessDataContext ctx)
        {
            //Insert Address
            Guid    addressId = Guid.NewGuid();
            Address address   = new Address
            {
                Id       = addressId,
                Address1 = ""
            };

            ctx.Addresses.InsertOnSubmit(address);
            ctx.SubmitChanges();
            return(addressId);
        }
示例#4
0
        /// <summary>
        /// InsertRegistrationPoints
        /// </summary>
        /// <param name="userId"></param>
        private void InsertRegistrationPoints(Guid userId)
        {
            DataAccessDataContext ctx = new DataAccessDataContext();
            var urPoints = ctx.PointConfigurations.Where(@w => @w.Type == "UR").First();

            Point point = new Point
            {
                Id     = Guid.NewGuid(),
                Point1 = urPoints.Point,
                UserId = userId
            };

            ctx.Points.InsertOnSubmit(point);
            ctx.SubmitChanges();
        }
示例#5
0
        /// <summary>
        /// InsertAuthSingleMetaData
        /// </summary>
        /// <param name="applicationId"></param>
        /// <param name="key"></param>
        /// <param name="ctx"></param>
        /// <returns></returns>
        private static Guid InsertAuthSingleMetaData(string applicationId, string gcmToken, string refCode, string genRefCode, string key, DataAccessDataContext ctx)
        {
            //Insert Auth key
            Guid authId     = Guid.NewGuid();
            Auth authSingle = new Auth
            {
                Id            = authId,
                GCMToken      = gcmToken,
                REFCODE       = genRefCode,
                Key           = key,
                ApplicationId = applicationId
            };

            ctx.Auths.InsertOnSubmit(authSingle);
            ctx.SubmitChanges();
            return(authId);
        }
示例#6
0
        /// <summary>
        /// InsertUserMetaData
        /// </summary>
        /// <param name="name"></param>
        /// <param name="mobile"></param>
        /// <param name="ctx"></param>
        /// <param name="cityId"></param>
        /// <param name="addressId"></param>
        /// <param name="authId"></param>
        private static void InsertUserMetaData(string name, string mobile, DataAccessDataContext ctx, Guid cityId, Guid addressId, Guid authId)
        {
            //Insert User Information.
            Guid userId = Guid.NewGuid();
            User user   = new User
            {
                Id        = userId,
                Name      = name,
                Mobile    = mobile,
                CityId    = cityId,
                AddressId = addressId,
                Active    = true,
                AuthId    = authId
            };

            ctx.Users.InsertOnSubmit(user);
            ctx.SubmitChanges();
        }
示例#7
0
        public int DeleteAllUsers()
        {
            DataAccessDataContext ctx = new DataAccessDataContext();

            var userList = ctx.Users.ToList();

            ctx.Users.DeleteAllOnSubmit(userList);

            var addressList = ctx.Addresses.ToList();

            ctx.Addresses.DeleteAllOnSubmit(addressList);

            var authList = ctx.Auths.ToList();

            ctx.Auths.DeleteAllOnSubmit(authList);

            ctx.SubmitChanges();

            return(204);
        }
示例#8
0
        /// <summary>
        /// InsertAddressMetaData
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        private static Guid InsertAddressMetaData(DataAccessDataContext ctx, Guid userId)
        {
            //Insert Address
            Guid    addressId = Guid.NewGuid();
            Address address   = new Address
            {
                Id         = addressId,
                HouseNo    = "",
                Street     = "",
                Locality   = "",
                WardId     = Guid.NewGuid(),
                PINCODE    = 560093,
                Registered = false,
                UserId     = userId
            };

            ctx.Addresses.InsertOnSubmit(address);
            ctx.SubmitChanges();
            return(addressId);
        }
示例#9
0
        /// <summary>
        /// Signin User
        /// </summary>
        /// <param name="name"></param>
        /// <param name="mobile"></param>
        /// <param name="cityCode"></param>
        /// <returns></returns>
        public int SigninUser(string name, string mobile, string cityCode, string gcmToken)
        {
            DataAccessDataContext ctx = new DataAccessDataContext();
            var  user     = ctx.Users.Where(@w => @w.Name == name && @w.Mobile == mobile);
            bool isExists = user.Count() == 1;

            if (!isExists)
            {
                return(103);
            }
            else
            {
                if (!string.IsNullOrEmpty(gcmToken))
                {
                    var authSingle = ctx.Auths.Where(@w => @w.Id == user.First().AuthId).First();
                    authSingle.GCMToken = gcmToken;
                    ctx.SubmitChanges();
                }

                return(202);
            }
        }