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)); } }
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); }
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); }