Beispiel #1
0
        public async Task <UserInfo> GetUserInfoAsync(string account, string channelName, string channelId)
        {
            using (var ctx = new UserInfoEntities(this.connectionString))
            {
                var entitiy = await ctx.UserInfos.SingleOrDefaultAsync(f => f.Account == account && f.ChannelId == channelId && f.ChannelName == channelName);

                return(entitiy);
            }
        }
Beispiel #2
0
        public async Task DeleteSocialLoginAccountDataAsync(string account)
        {
            using (var ctx = new UserInfoEntities(this.connectionString))
            {
                var entities = await ctx.UserInfos.Where(f => f.Account == account).ToListAsync();

                if (entities == null || !entities.Any())
                {
                    return;
                }

                ctx.UserInfos.RemoveRange(entities);
                await ctx.SaveChangesAsync();
            }
        }
Beispiel #3
0
        public async Task DeleteUserInfoAsync(string account, string channelName, string channelId)
        {
            using (var ctx = new UserInfoEntities(this.connectionString))
            {
                var entities = await ctx.UserInfos.Where(f => f.Account == account && f.ChannelId == channelId && f.ChannelName == channelName).ToListAsync();

                if (entities == null || !entities.Any())
                {
                    return;
                }

                // Remove profiles
                ctx.UserInfos.RemoveRange(entities);
                await ctx.SaveChangesAsync();
            }
        }
Beispiel #4
0
 public ActionResult Login(Table usr)
 {
     if (ModelState.IsValid)
     {
         using (UserInfoEntities uie = new UserInfoEntities())
         {
             var v = uie.Tables.Where(a => a.Username.Equals(usr.Username) && a.Password.Equals(usr.Password)).FirstOrDefault();
             if (v != null)
             {
                 Session["LogedUserID"]       = v.UserID.ToString();
                 Session["LogedUserFullname"] = v.Fullname.ToString();
                 return(RedirectToAction("AfterLogin"));
             }
         }
     }
     return(View(usr));
 }
Beispiel #5
0
        public List <UserInfoEntities> UpdateAccount(MRequest request)
        {
            UserInfoEntities        users    = null;
            List <UserInfoEntities> accounts = new List <UserInfoEntities>();

            try
            {
                using (var conn = DALHelper.GetConnection())
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = DBConstants.UserManagement.Update_Account;
                        cmd.Parameters.AddWithValue("@UserName", request.User.UserName);
                        cmd.Parameters.AddWithValue("@UserPassword", request.User.Password);
                        cmd.Parameters.AddWithValue("@MobileNumber", request.User.MobileNumber);
                        cmd.Parameters.AddWithValue("@Email", request.User.Email);
                        cmd.Parameters.AddWithValue("@Hospital", request.User.Hospital);
                        cmd.Parameters.AddWithValue("@UserId", request.User.UserId);
                        conn.Open();

                        // UserId = Convert.ToInt32(cmd.ExecuteScalar());
                        SqlDataReader dr = cmd.ExecuteReader();
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                users              = new UserInfoEntities();
                                users.UserId       = Convert.ToInt32(dr["UserId"]);
                                users.UserName     = Convert.ToString(dr["UserName"]);
                                users.Password     = Convert.ToString(dr["UserPassword"]);
                                users.MobileNumber = Convert.ToString(dr["MobileNumber"]);
                                users.Email        = Convert.ToString(dr["Email"]);
                                users.Hospital     = Convert.ToString(dr["Hospital"]);
                                accounts.Add(users);
                            }
                        }
                        conn.Close();
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(accounts);
        }
Beispiel #6
0
        public async Task <UserInfoResult> CreateorUpdateUserInfoAsync(string account, string channelId, UserInfoRecordDescription description)
        {
            using (var ctx = new UserInfoEntities(this.connectionString))
            {
                UserInfoResult userInfoResult = new UserInfoResult();
                byte[]         serializedProfileDescription;
                using (MemoryStream stream = new MemoryStream())
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(stream, description);
                    serializedProfileDescription = stream.ToArray();
                }

                var profile = await ctx.UserInfos.SingleOrDefaultAsync(f => f.Account == account && f.ChannelId == channelId && f.ChannelName == description.Channel);

                var startTime = DateTime.UtcNow;
                if (profile == null)
                {
                    profile = new UserInfo
                    {
                        Account           = account,
                        ChannelName       = description.Channel,
                        ChannelId         = channelId,
                        ChannelProperties = serializedProfileDescription,
                        CreatedTime       = startTime,
                        ModifiedTime      = startTime
                    };

                    ctx.UserInfos.Add(profile);
                    userInfoResult.Action = ActionType.Create;
                }
                else
                {
                    profile.ChannelProperties = serializedProfileDescription;
                    profile.ModifiedTime      = startTime;
                    userInfoResult.Action     = ActionType.Update;
                }

                await ctx.SaveChangesAsync();

                userInfoResult.UserInfo = profile;
                return(userInfoResult);
            }
        }
Beispiel #7
0
        public List <UserInfoEntities> FetchAccounts(string hospital)
        {
            UserInfoEntities        users    = null;
            List <UserInfoEntities> accounts = new List <UserInfoEntities>();

            try
            {
                using (var conn = DALHelper.GetConnection())
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = DBConstants.UserManagement.Fetch_Users;
                        cmd.Parameters.AddWithValue("@Hospital", hospital);
                        conn.Open();
                        SqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            users              = new UserInfoEntities();
                            users.UserId       = Convert.ToInt32(dr["UserId"]);
                            users.UserName     = Convert.ToString(dr["UserName"]);
                            users.Password     = Convert.ToString(dr["UserPassword"]);
                            users.MobileNumber = Convert.ToString(dr["MobileNumber"]);
                            users.Email        = Convert.ToString(dr["Email"]);
                            users.Hospital     = Convert.ToString(dr["Hospital"]);
                            accounts.Add(users);
                        }
                        conn.Close();
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(accounts);
        }