public PropertyDto AddProperty(int landlordId, PropertyBaseDto property) { try { var itemToCreate = _mapper.Map <Domain.Entities.Property>(property); itemToCreate.LandlordId = landlordId; _rep.Add(itemToCreate); _rep.Save(); var createdDto = _mapper.Map <PropertyDto>(itemToCreate); return(createdDto); } catch (Exception e) { //Logger.ErrorException(e.Message, e); throw e; } }
public CustomerDto AddCustomer(CustomerBaseDto customer) { try { var itemToCreate = Mapper.Map <Customer>(customer); _rep.Add(itemToCreate); if (!_rep.Save()) { return(null); } var customerDto = Mapper.Map <CustomerDto>(itemToCreate); return(customerDto); } catch (Exception e) { //Logger.ErrorException(e.Message, e); throw e; } }
public TransactionDto AddTransaction(int customerId, TransactionBaseDto transaction) { try { var itemToCreate = Mapper.Map <Transaction>(transaction); itemToCreate.CustomerId = customerId; _rep.Add(itemToCreate); if (!_rep.Save()) { return(null); } var createdDto = Mapper.Map <TransactionDto>(itemToCreate); return(createdDto); } catch (Exception e) { //Logger.ErrorException(e.Message, e); throw e; } }
public StudentDto AddStudent(StudentDto student) { try { var itemToCreate = _mapper.Map <Student>(student); _rep.Add(itemToCreate); _rep.Save(); var createdDto = _mapper.Map <StudentDto>(itemToCreate); return(createdDto); } catch (Exception e) { throw e; } }
public TransactionDTo AddTransaction(string customerId, TransactionDTo transaction) { try { Enum.TryParse(transaction.Type, out EquipmentType equipmentType); transaction.Points = Helper.CalculatePoints(equipmentType); transaction.Price = Helper.CalculatePrice(transaction.Days, equipmentType); transaction.TransactionDateTime = DateTime.Now.ToString(); var itemToCreate = Mapper.Map <Transaction>(transaction); itemToCreate.UserId = customerId; _rep.Add(itemToCreate); if (!_rep.Save()) { return(null); } var transactionDTo = Mapper.Map <TransactionDTo>(itemToCreate); return(transactionDTo); } catch (Exception e) { _logger.LogInformation(e.Message); throw; } }
public TransactionDTo AddTransaction(string customerId, TransactionDTo transaction) { try { Enum.TryParse(transaction.Type, out EquipmentType equipmentType); transaction.Points = Helper.CalculatePoints(equipmentType); transaction.Price = Helper.CalculatePrice(transaction.Days, equipmentType); transaction.TransactionDateTime = DateTime.Now.ToString(); transaction.UserId = customerId; _rep.Add(transaction); return(!_rep.Save() ? null : transaction); } catch (Exception e) { //Logger.ErrorException(e.Message, e); throw e; } }