コード例 #1
0
ファイル: UserController.cs プロジェクト: sbudihar/SIRIUSrepo
        public ActionResult Delete(Int64 id)
        {
            User user = UserService.GetUser(id);

            if (user == null)
            {
                this.ShowNotification(NotificationType.Info, "User tidak ditemukan", true);
                return RedirectToAction("Index");
            }

            var userData = new UserUpdateModel();
            Mapper.Map(user, userData);
            return View(userData);
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: sbudihar/SIRIUSrepo
        public ActionResult Delete(UserUpdateModel userCreateUpdateModel)
        {
            //Thread.Sleep(5000);
            var userToDelete = new User();
            Mapper.Map(userCreateUpdateModel, userToDelete);
            UserService.DeleteUser(userToDelete);

            this.ShowNotification(NotificationType.Success, "User berhasil dihapus", true);
            return RedirectToAction("Index");
        }
コード例 #3
0
ファイル: UserController.cs プロジェクト: sbudihar/SIRIUSrepo
        public ActionResult Edit(UserUpdateModel userUpdateModel)
        {
            //ModelState.Remove("Password");
            //ModelState.Remove("ConfirmPassword");
            //Thread.Sleep(5000);
            //if (ModelState.IsValid)
            //{
            User userToUpdate = UserService.GetUser(userUpdateModel.UserId);

            if (userToUpdate == null)
            {
                //this.ShowNotification(NotificationType.Info, "User tidak ditemukan", true);
                //return RedirectToAction("Index");
                throw new CustomException(ExceptionType.DeletedByOtherUser, "", null);
            }

            Mapper.Map(userUpdateModel, userToUpdate);
            //userToUpdate.Login = "******";
            UserService.UpdateUser(userToUpdate);

            this.ShowNotification(NotificationType.Success, "User berhasil diubah", true);

            return RedirectToAction("Index");
            //}
            //return View();
        }