Esempio n. 1
0
        public ActionResult Delete(DetailUser user)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UserBase userDelete = DataBase.Users.Get(p => p.UserId == user.UserId, includeProperties: "UserRole").SingleOrDefault();
                    if (userDelete.IsPrivate)
                    {
                        return(RedirectToAction("Index"));
                    }

                    DataBase.Users.Delete(userDelete);

                    List <UserRoleBase> useRole = userDelete.UserRole.ToList();
                    foreach (var roleBase in useRole)
                    {
                        DataBase.UserRoles.Delete(roleBase);
                    }

                    DataBase.Save();

                    return(RedirectToAction("Index"));
                }
            }catch
            {
                this.AddDefaultErrorMessage();
            }

            return(View(user));
        }
Esempio n. 2
0
 public int Update(DetailUser detailUser)
 {
     return(__sqlMapper.Execute(new RequestContext
     {
         Scope = "DetailUser",
         SqlId = "Update",
         Request = detailUser
     }));
 }
Esempio n. 3
0
 public long Save(DetailUser detailUser)
 {
     return(__sqlMapper.ExecuteScalar <long>(new RequestContext
     {
         Scope = "DetailUser",
         SqlId = "Insert",
         Request = detailUser
     }));
 }
        public ApiResponse <DetailUser> FindById(long id)
        {
            ApiResponse <DetailUser> apiResponse = ApiResponse <DetailUser> .GetInstance();

            try
            {
                DetailUser detailUser = __detailUserDao.FindById(id);
                apiResponse.Success(detailUser);
            }
            catch (System.Exception)
            {
                throw;
            }

            return(apiResponse);
        }
        public ApiResponse <bool> Update(DetailUser detailUser)
        {
            ApiResponse <bool> apiResponse = ApiResponse <bool> .GetInstance();

            if (null == detailUser)
            {
                return(apiResponse.Error());
            }

            try
            {
                __detailUserDao.Update(detailUser);
                apiResponse.Success(true);
            }
            catch (System.Exception)
            {
                throw;
            }

            return(apiResponse);
        }
        public ApiResponse <long> Save(DetailUser detailUser)
        {
            ApiResponse <long> apiResponse = ApiResponse <long> .GetInstance();

            if (null == detailUser)
            {
                return(apiResponse.Error());
            }

            try
            {
                long id = __detailUserDao.Save(detailUser);
                apiResponse.Success(id);
            }
            catch (System.Exception)
            {
                throw;
            }

            return(apiResponse);
        }
 public ApiResponse <bool> Update(DetailUser detailUser)
 {
     return(__detailUserService.Update(detailUser));
 }
 public ApiResponse <long> Save(DetailUser detailUser)
 {
     return(__detailUserService.Save(detailUser));
 }
Esempio n. 9
0
        public void FindByIdTest()
        {
            DetailUser detailUser = detailUserDaoImpl.FindById(2);

            Assert.True(null != detailUser);
        }