コード例 #1
0
        // GET: UserAccounts/Details/5
        public ActionResult Details(int?id)
        {
            int idSought = id ?? 1;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Memom.Entities.Models.UserAccount UserAccount = this.userSvc.FindUser(idSought);
            if (UserAccount == null)
            {
                return(HttpNotFound());
            }
            return(View(UserAccount));
        }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "UserKey,Username,FirstName,LastName,DisplayName,IsAccountClosed,IsLoginAllowed,RequiresPasswordReset,Age,Email,IsAccountVerified")] UserAccountInput UserAccountInput)
        {
            if (ModelState.IsValid)
            {
                Memom.Entities.Models.UserAccount UserAccount = UserAccountConvert(UserAccountInput);
                UserAccount.LastUpdated = DateTime.Now;
                try
                {
                    this.userSvc.Update(UserAccount);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(UserAccountInput));
                }

                return(RedirectToAction("Index"));
            }
            return(View(UserAccountInput));
        }
コード例 #3
0
        private UserAccountInput UserAccountConvert(Memom.Entities.Models.UserAccount UserAccount)
        {
            UserAccountInput UserAccountInput = new UserAccountInput();

            if (UserAccount != null)
            {
                UserAccountInput.UserKey               = UserAccount.Key; //.ToString();
                UserAccountInput.Username              = UserAccount.Username;
                UserAccountInput.FirstName             = UserAccount.FirstName;
                UserAccountInput.LastName              = UserAccount.LastName;
                UserAccountInput.DisplayName           = UserAccount.DisplayName;
                UserAccountInput.Age                   = UserAccount.Age;
                UserAccountInput.IsAccountClosed       = UserAccount.IsAccountClosed;
                UserAccountInput.IsLoginAllowed        = UserAccount.IsLoginAllowed;
                UserAccountInput.RequiresPasswordReset = UserAccount.RequiresPasswordReset;
                UserAccountInput.Email                 = UserAccount.Email;
                UserAccountInput.IsAccountVerified     = UserAccount.IsAccountVerified;
            }

            return(UserAccountInput);
        }
コード例 #4
0
 public ActionResult DeleteConfirmed(int id)
 {
     ViewBag.ErrorMessage = "";
     Memom.Entities.Models.UserAccount UserAccount = this.userSvc.FindUser(id);
     if (UserAccount == null)
     {
         return(HttpNotFound());
     }
     else
     {
         try
         {
             this.userSvc.Delete(id);
         }
         catch (Exception ex)
         {
             ViewBag.ErrorMessage = ex.Message;
             return(View("CustomError"));
         }
     }
     return(RedirectToAction("Index"));
 }
コード例 #5
0
        private Memom.Entities.Models.UserAccount UserAccountConvert(UserAccountInput UserAccountInput)
        {
            Memom.Entities.Models.UserAccount UserAccount = null;

            if (UserAccountInput != null)
            {
                UserAccount = this.userSvc.FindUser(UserAccountInput.UserKey);

                //UserAccount.Username = UserAccountInput.Username;
                UserAccount.FirstName             = UserAccountInput.FirstName;
                UserAccount.LastName              = UserAccountInput.LastName;
                UserAccount.DisplayName           = UserAccountInput.DisplayName;
                UserAccount.Age                   = UserAccountInput.Age;
                UserAccount.IsAccountClosed       = UserAccountInput.IsAccountClosed;
                UserAccount.IsLoginAllowed        = UserAccountInput.IsLoginAllowed;
                UserAccount.RequiresPasswordReset = UserAccountInput.RequiresPasswordReset;
                //UserAccount.Email = UserAccountInput.Email;
                UserAccount.IsAccountVerified = UserAccountInput.IsAccountVerified;
                //UserAccount.LastUpdated = System.DateTime.Now;
            }

            return(UserAccount);
        }
コード例 #6
0
        private LoginApiAccount PrepareLoginSuccessData(Memom.Entities.Models.UserAccount userAccount)
        {
            LoginApiAccount apiAccount = new LoginApiAccount();

            apiAccount.FirstName             = userAccount.FirstName;
            apiAccount.LastName              = userAccount.LastName;
            apiAccount.DisplayName           = userAccount.DisplayName;
            apiAccount.LastLogin             = userAccount.LastLogin;
            apiAccount.RequiresPasswordReset = userAccount.RequiresPasswordReset;
            apiAccount.ID    = userAccount.ID;
            apiAccount.Key   = userAccount.Key;
            apiAccount.Email = userAccount.Email;

            // do this further processing only when reset password is not needed, if not ask teh user to chnage password

            if (!userAccount.RequiresPasswordReset)
            {
                foreach (Album userAlbum in userAccount.Albums)
                {
                    ApiUserAlbum sample = new ApiUserAlbum();
                    sample = new ApiUserAlbum
                    {
                        Key       = userAlbum.Key,
                        AlbumName = userAlbum.Name,
                    };

                    apiAccount.UserAlbums.Add(new ApiUserAlbum
                    {
                        Key       = userAlbum.Key,
                        AlbumName = userAlbum.Name,
                    });
                }
            }

            return(apiAccount);
        }