private UserEntryModel GetUpdateStateModel(int userPK)
        {
            UserEntryFormData formData     = new UserEntryFormData();
            List <Control>    formControls = CreateFormControls(userPK);
            UserDTO           userDTO      = userQuery.GetByPrimaryKey(userPK);

            if (userDTO == null)
            {
                throw new KairosException($"Record with primary key '{userDTO.User_PK}' is not found.");
            }

            var kategoriJabatan = new KategoriJabatanQuery(this.Db).GetByPrimaryKey(userDTO.KategoriJabatan_FK);

            if (kategoriJabatan != null)
            {
                formData.KategoriJabatans.Add(kategoriJabatan);
            }

            return(new UserEntryModel()
            {
                FormData = formData,
                FormControls = formControls,
                Model = userDTO,
            });
        }
 public IHttpActionResult Get(int id)
 {
     ThrowIfUserHasNoRole(readRole);
     using (UserQuery userQuery = new UserQuery(Db))
     {
         var data = userQuery.GetByPrimaryKey(id);
         SaveLog("User", "Get", JsonConvert.SerializeObject(new { primaryKey = id }));
         return(Ok(new SuccessResponse(data)));
     }
 }
Beispiel #3
0
        public IHttpActionResult Get(int id)
        {
            string accessType = "User_ViewAll";

            ThrowIfUserCannotAccess(accessType);
            using (UserQuery userQuery = new UserQuery(Db))
            {
                var data = userQuery.GetByPrimaryKey(id);
                SaveLog("User", "Get", JsonConvert.SerializeObject(new { primaryKey = id }));
                return(Ok(new SuccessResponse(data)));
            }
        }