Пример #1
0
        public JsonResult UpdateProfilePicture(ProfilePicture selection)
        {
            var timeNow         = DateTime.UtcNow;
            var formattedString = GlobalAppSettings.GetFormattedTimeZone(timeNow, selection.UserId);
            var imageName       = _userProfile.UpdateUserAvatarDetails(selection, timeNow);

            return(Json(new { imageName, formattedString }));
        }
Пример #2
0
        public JsonResult TransferImage(string path, string username)
        {
            var      userId          = _userDetails.GetUserId(username);
            DateTime timeNow         = DateTime.UtcNow;
            var      formattedString = GlobalAppSettings.GetFormattedTimeZone(timeNow, userId);
            var      imageName       = _userProfile.DefaultavatarTransfer(path, username, timeNow);

            return(Json(new { imageName, formattedString }));
        }
Пример #3
0
        public JsonResult UpdateUserProfile()
        {
            int userId             = _userDetails.GetUserId(HttpContext.Request["username"]);
            var userDetails        = new UserManagement();
            var currentUserDetails = _userDetails.FindUserByUserId(userId);
            var currentEmail       = currentUserDetails.Email;
            var timeNow            = DateTime.UtcNow;

            if (currentEmail != HttpContext.Request["email"])
            {
                var emailList = _userDetails.GetAllActiveEmails();

                var isEmailExist = emailList.Find(f => f.Email == HttpContext.Request["email"]) == null;

                if (isEmailExist)
                {
                    var updateColumns = new List <UpdateColumn>
                    {
                        new UpdateColumn
                        {
                            ColumnName = GlobalAppSettings.DbColumns.DB_User.Email,
                            Value      = HttpContext.Request["email"]
                        }
                    };
                    this._userDetails.UpdateUserProfileDetails(updateColumns, userId);
                }
                else
                {
                    var result = new { status = false, key = "email", value = "E-mail already exists" };
                    return(Json(new { Data = result }));
                }
            }
            try
            {
                var fullName = currentUserDetails.FirstName;

                if (fullName != HttpContext.Request["firstname"])
                {
                    var updateColumns = new List <UpdateColumn>
                    {
                        new UpdateColumn
                        {
                            ColumnName = GlobalAppSettings.DbColumns.DB_User.FirstName,
                            Value      = HttpContext.Request["fullname"]
                        }
                    };
                    _userDetails.UpdateUserProfileDetails(updateColumns, userId);
                }
                var updateDetails = new List <UpdateColumn>
                {
                    new UpdateColumn
                    {
                        ColumnName = GlobalAppSettings.DbColumns.DB_User.FirstName,
                        Value      = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["firstname"])
                    },
                    new UpdateColumn
                    {
                        ColumnName = GlobalAppSettings.DbColumns.DB_User.LastName,
                        Value      = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["lastname"])
                    },
                    new UpdateColumn
                    {
                        ColumnName = GlobalAppSettings.DbColumns.DB_User.Contact,
                        Value      = HttpContext.Request["mobile"]
                    },
                    new UpdateColumn
                    {
                        ColumnName = GlobalAppSettings.DbColumns.DB_User.DisplayName,
                        Value      =
                            CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["firstname"]) + " " +
                            CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["lastname"])
                    },
                    new UpdateColumn {
                        ColumnName = GlobalAppSettings.DbColumns.DB_User.ModifiedDate, Value = timeNow.ToString(GlobalAppSettings.GetDateTimeFormat())
                    }
                };
                _userDetails.UpdateUserProfileDetails(updateDetails, userId);
                HttpContext.Session["displayname"] = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["firstname"]) + " " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["lastname"]);
            }
            catch (Exception)
            {
                var result = new { status = false, key = "error", value = "User profile updation failed." };
                return(Json(new { Data = result }));
            }
            var formattedString = GlobalAppSettings.GetFormattedTimeZone(timeNow, userId);
            var finalResult     = new { status = true, key = "success", value = "User Profile has been updated successfully." };

            return(Json(new { Data = finalResult, formattedString }));
        }