예제 #1
0
 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;
     }
 }
예제 #2
0
 public TransactionDto AddTransaction(int customerId, TransactionBaseDto transaction)
 {
     try
     {
         var itemToCreate = Mapper.Map <TransactionDto>(transaction);
         itemToCreate.CustomerId = customerId;
         _rep.Add(itemToCreate);
         return(!_rep.Save() ? null : itemToCreate);
     }
     catch (Exception e)
     {
         //Logger.ErrorException(e.Message, e);
         throw e;
     }
 }
예제 #3
0
 public CustomerDto AddCustomer(CustomerBaseDto customer)
 {
     try
     {
         var itemToCreate = Mapper.Map <CustomerDto>(customer);
         var id           = MockData.Current.Customers.AsEnumerable().Max(m => m.CustomerId) + 1;
         itemToCreate.CustomerId = id;
         _rep.Add(itemToCreate);
         //if (!_rep.Save()) return null;
         return(itemToCreate);
     }
     catch (Exception e)
     {
         //Logger.ErrorException(e.Message, e);
         throw e;
     }
 }
 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;
     }
 }
예제 #5
0
 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;
     }
 }
예제 #6
0
 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;
     }
 }
예제 #7
0
 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;
     }
 }