예제 #1
0
        public HttpResponseMessage Put([FromBody] Models.role role)
        {
            try
            {
                if (string.IsNullOrEmpty(role.role_name))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Role Name is Empty"
                    }, formatter));
                }
                else
                {
                    Models.role updateRole = new Models.role
                    {
                        role_id    = role.role_id,
                        role_name  = role.role_name,
                        is_active  = role.is_active,
                        updated_by = role.updated_by,
                        //updated_date = DateTime.Now.ToString(),
                        is_fixed     = role.is_fixed,
                        role_type_id = role.role_type_id
                    };

                    bool roleUpdate = roleRepository.UpdateRole(updateRole);

                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "success", msg = "Role Update successfully"
                    }, formatter));
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }