public IList <Operatie> GetAllOperations() { try { _operatieRead = new ReadOperatieRepository(context); return(_operatieRead.GetAll().ToList()); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Gets the client autos. /// </summary> /// <param name="clientId">The client identifier.</param> /// <returns>IList<Auto>.</returns> /// <exception cref="NotImplementedException"></exception> public IList <Auto> GetClientAutos(int clientId) { try { _autoRead = new ReadAutoRepository(_context); return(_autoRead.GetAutoByClient(clientId)); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
public IList <Comanda> GetAllDoneOrders() { try { _comandaRead = new ReadComandaRepository(context); return(_comandaRead.GetAll().Where(comanda => comanda.StareComanda == StareComanda.Executata).ToList()); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Gets all detaliu comenzii. /// </summary> /// <returns>IList<DetaliuComanda>.</returns> /// <exception cref="DbEntityCustomException"></exception> public IList <DetaliuComanda> GetAllDetaliuComandas() { try { _detaliuComandaRead = new ReadDetaliuComandaRepository(context); return(_detaliuComandaRead.GetAll().ToList()); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Gets all mecanics. /// </summary> /// <returns>IList<Mecanic>.</returns> /// <exception cref="DbEntityCustomException"></exception> public IList <Mecanic> GetAllMecanics() { try { _mecanicRead = new ReadMecanicRepository(context); return(_mecanicRead.GetAll().ToList()); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
public IList <Material> GetAvailabelMaterials() { try { _materialRead = new ReadMaterialRepository(context); return(_materialRead.GetAvailables()); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
public int GetOperationsTotalTime() { try { _operatieRead = new ReadOperatieRepository(context); var response = _operatieRead.GetAll().Where(operatie => operatie.TimpExecutie.HasValue).ToList(); return(Decimal.ToInt32((decimal)response.Sum(operatie => operatie.TimpExecutie))); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Creates the material. /// </summary> /// <param name="material">The material.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateMaterial(Material material) { try { _materialWrite = new WriteMaterialRepository(_context); _materialWrite.Create(material); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Creates the automatic. /// </summary> /// <param name="auto">The automatic.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateAuto(Auto auto) { try { _autoWrite = new WriteAutoRepository(_context); _autoWrite.Create(auto); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Creates the client. /// </summary> /// <param name="client">The client.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateClient(Client client) { try { _clientWrite = new WriteClientRepository(_context); _clientWrite.Create(client); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Creates the mecanic. /// </summary> /// <param name="mecanic">The mecanic.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateMecanic(Mecanic mecanic) { try { _mecanicWrite = new WriteMecanicRepository(_context); _mecanicWrite.Create(mecanic); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Creates the operatie. /// </summary> /// <param name="operatie">The operatie.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateOperatie(Operatie operatie) { try { _operatieWrite = new WriteOperatieRepository(_context); _operatieWrite.Create(operatie); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Creates the imagine. /// </summary> /// <param name="imagine">The imagine.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateImagine(Imagine imagine) { try { _imagineWrite = new WriteImagineRepository(_context); _imagineWrite.Create(imagine); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Creates the detaliu comanda. /// </summary> /// <param name="detaliuComanda">The detaliu comanda.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateDetaliuComanda(DetaliuComanda detaliuComanda) { try { _detaliuComandaWrite = new WriteDetaliuComandaRepository(_context); _detaliuComandaWrite.Create(detaliuComanda); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
public void DeleteAllEntitiesOnTable(string tableName) { string databaseName = context.Database.Connection.Database; var count = context.Database.SqlQuery <int>($"SELECT COUNT(*) FROM [{databaseName}].[dbo].[{tableName}]"); if (count.Any() && count.First() > 0) { try { var setResponse = $"Deleted {count.First()} items from {tableName}"; context.Database.ExecuteSqlCommand($"DELETE FROM {tableName}"); Logger.Log.Handle(LogLevel.Info, setResponse); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } } }
/// <inheritdoc /> /// <summary> /// Adds the mecanics. /// </summary> /// <param name="selectedMecanics">The selected mecanics.</param> /// <param name="detaliuComanda">The detaliu comanda.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> /// <exception cref="DbEntityCustomException"></exception> public bool AddMecanics(List <Mecanic> selectedMecanics, DetaliuComanda detaliuComanda) { try { _detaliuComandaWrite = new WriteDetaliuComandaRepository(context); foreach (var selectedMecanic in selectedMecanics) { detaliuComanda.Mecanici.Add(selectedMecanic); } _detaliuComandaWrite.Update(detaliuComanda); context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Adds the operatie. /// </summary> /// <param name="operatie">The operatie.</param> /// <param name="detaliuComanda">The detaliu comanda.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> /// <exception cref="DbEntityCustomException"></exception> public bool AddOperatie(Operatie operatie, DetaliuComanda detaliuComanda) { try { _operatieWrite = new WriteOperatieRepository(context); _detaliuComandaWrite = new WriteDetaliuComandaRepository(context); _operatieWrite.Create(operatie); if (detaliuComanda.Operaties == null) { detaliuComanda.Operaties = new List <Operatie>(); } detaliuComanda.Operaties.Add(operatie); _detaliuComandaWrite.Update(detaliuComanda); context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
/// <inheritdoc /> /// <summary> /// Searches the client. /// </summary> /// <param name="searchClientString">Search by SerieSasiu, Telefon, Email</param> /// <returns>System.Int32.</returns> /// <exception cref="NotImplementedException"></exception> public Client GetClient(string searchClientString) { try { _clientRead = new ReadClientRepository(_context); if (searchClientString.Contains("@")) { return(_clientRead.GetByEmail(searchClientString)); } if (searchClientString.Contains("+") || IsDigitsOnly(searchClientString)) { return(_clientRead.GetByTelefon(searchClientString)); } return(_clientRead.GetBySerieSasiu(searchClientString)); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }