public async Task <ExecutionStatus> Run(Judge entity, ByWhatId byWhatId) { using var connection = new SqliteConnection(_geekLemonContext.ConnectionString); //Nie ma SQL INjection var q2 = @"UPDATE Judges SET Login = @Login, Password = @Password, BirthDate=@BirthDate ,Name_First = @Name_First, Name_Last = @Name_Last WHERE Id = @Id; "; var q = @"UPDATE Judges SET Login = @Login, Password = @Password, BirthDate=@BirthDate ,Name_First = @Name_First, Name_Last = @Name_Last WHERE UniqueId = @UniqueId; "; var temp = _mapper.Map <JudgeTemp>(entity); try { if (byWhatId == ByWhatId.CreatedId) { q = q2; } var result = await connection.ExecuteAsync(q, temp); return(ExecutionStatus.DbOk()); } catch (Exception ex) { return(ExecutionStatus.DbError(ex.Message)); } }
public async Task <ExecutionStatus> Run(Category entity, ByWhatId byWhatId) { using var connection = new SqliteConnection(_geekLemonContext.ConnectionString); //Nie ma SQL INjection var q1 = @"UPDATE Categories SET Name = @Name, DisplayName = @DisplayName, WhatWeAreLookingFor=@WhatWeAreLookingFor ,Version = @Version WHERE UniqueId = @UniqueId; "; var q = @"UPDATE Categories SET Name = @Name, DisplayName = @DisplayName, WhatWeAreLookingFor=@WhatWeAreLookingFor ,Version = @Version WHERE Id = @Id; "; try { if (byWhatId == ByWhatId.UniqueId) { q = q1; } var result = await connection.QueryAsync <int>(q, new { @UniqueId = entity.UniqueId.Value.ToString(), @Id = entity.Id.Value, @Name = entity.Name, @Version = entity.Version, @DisplayName = entity.DisplayName, @WhatWeAreLookingFor = entity.WhatWeAreLookingFor }); return(ExecutionStatus.DbOk()); } catch (Exception ex) { if (ExecutionFlow.Options.ThrowExceptions) { throw; } return(ExecutionStatus.DbError(ex)); } }