예제 #1
0
 public async Task <IActionResult> CreateSource([FromBody] ModifyRoleDTO source)
 {
     try
     {
         if (source == null)
         {
             return(BadRequest());
         }
         if (!ModelState.IsValid)
         {
             return(BadRequest("Invalid model object"));
         }
         var sourceEntity = _mapper.Map <Role>(source);
         return(Ok(await _repositoryWrapper.RoleRepo.NewData(sourceEntity)));
     }
     catch (Exception ex)
     {
         //_logger.LogError($"Something went wrong inside CreateSources action: {ex.Message}");
         if (ex.InnerException != null)
         {
             return(BadRequest(ex.Message + "," + ex.InnerException.Message));
         }
         return(BadRequest(ex.Message));
     }
 }
예제 #2
0
        public HttpResponseMessage ModifyRole(ModifyRoleDTO obj)
        {
            HttpResponseMessage message;

            try
            {
                RoleDAL dal    = new RoleDAL();
                var     dynobj = new { result = dal.ModifyRole(obj) };
                message = Request.CreateResponse(HttpStatusCode.OK, dynobj);
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "something Wrong.Try Again!" });
            }
            return(message);
        }
예제 #3
0
        public bool ModifyRole(ModifyRoleDTO obj)
        {
            bool res = false;

            obj.ModifiedBy = "1002";
            SqlCommand cmd = new SqlCommand("sp_ModifyRole");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@P_RoleId", obj.RoleId);
            cmd.Parameters.AddWithValue("@p_Name", obj.Name);
            cmd.Parameters.AddWithValue("@p_Code", obj.Code);
            cmd.Parameters.AddWithValue("@p_ActionBy", obj.ModifiedBy);
            int result = new DBlayer().ExecuteNonQuery(cmd);

            if (result != Int32.MaxValue)
            {
                res = true;
            }
            return(res);
        }