public void InsertColor(Domain.Nitaqat.Color color) { using (var dbContextScope = _dbContextScopeFactory.Create()) { _colorRepository.Add(color); dbContextScope.SaveChanges(); } }
public Domain.Nitaqat.Color GetColorById(int colorId) { using (var dbContextScope = _dbContextScopeFactory.CreateReadOnly()) { Domain.Nitaqat.Color color = _colorRepository.GetById(colorId); if (color == null) { throw new ArgumentException($"Invalid value provided for {nameof(colorId)}: [{colorId}]. Couldn't find a user with this ID."); } return(color); } }
public void UpdateColor(Domain.Nitaqat.Color color) { using (var dbContextScope = _dbContextScopeFactory.Create()) { Domain.Nitaqat.Color colorToUpdate = _colorRepository.GetById(color.Id); if (colorToUpdate == null) { throw new ArgumentException($"Invalid {nameof(colorToUpdate)} provided: {0}. Couldn't find a User with this ID."); } // Simulate the calculation of a credit score taking some time colorToUpdate.Name = color.Name; dbContextScope.SaveChanges(); } }
public void DeleteColor(Domain.Nitaqat.Color Color) { throw new NotImplementedException(); }