public async Task <ActionResult> Create([FromBody] IdentificationTypeRequest request) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(await _identificationTypeService.Create(request))); } catch (Exception ex) { return(BadRequest()); } }
public async Task <int> Create(IdentificationTypeRequest data) { using (SqlConnection sql = new SqlConnection(_connectionString)) { using (SqlCommand cmd = new SqlCommand("usp_IdentificationTypes_Create", sql)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Name", data.Name)); cmd.Parameters.Add(new SqlParameter("@Code", data.Code)); await sql.OpenAsync(); int resp = await cmd.ExecuteNonQueryAsync(); sql.Close(); return(resp); } } }
public async Task <Response> Create(IdentificationTypeRequest model) { int result = await _identificationTypesRepository.Create(model); if (result == 1) { return(new Response { IsSuccess = true, Message = "Se creo exitosamente" }); } else { return(new Response { IsSuccess = false, Message = "No fue creada" }); } }
public async Task <Response> Update(IdentificationTypeRequest request) { int result = await _identificationTypesRepository.Update(request); if (result > 0) { return(new Response { IsSuccess = true, Message = "Se actualizó exitosamente", Result = result }); } else { return(new Response { IsSuccess = false, Message = "No fue actualizada correctamente" }); } }