public CustomerDTO Add(CustomerDTO customerDTO)
        {
            try
            {
                customerDTO.IsCustomerAlreadyExist = false;
                mapper = new CustomerMapper();

                customerDTO.ID = _bheUOW.CustomerRepository.Add(mapper.CustomerEntityMapper(customerDTO));

                _bheUOW.SaveChanges();
                return(customerDTO);
            }
            catch (Exception ex)
            {
                ExceptionHandler exceptionHandler = new ExceptionHandler();
                exceptionHandler.WrapLogException(ex);
                if (((SqlException)ex.InnerException.InnerException).Number == 2627)
                {
                    customerDTO.IsCustomerAlreadyExist = true;
                    return(customerDTO);
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 2
0
        public long Add(PartDTO partDTO)
        {
            try
            {
                Part part = new Part()
                {
                    CompanyID         = partDTO.CompanyID,
                    ListPrice         = partDTO.ListPrice,
                    Make              = partDTO.Make,
                    Model             = partDTO.Model,
                    PartDescription   = partDTO.PartDescription,
                    PartManual        = partDTO.PartManual,
                    PartNumber        = partDTO.PartNumber,
                    SerialNumberRange = partDTO.SerialNumberRange,
                    AddedBy           = "Admin",
                    AddedDate         = DateTime.Now,
                    IsDeleted         = false
                };

                var partID = _bheUOW.PartsRepository.Add(part);
                _bheUOW.SaveChanges();
                return(partID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public int Add(RepairDTO repairDTO)
 {
     try
     {
         Repair entity = RepairMapper.Map(repairDTO);
         _bheUOW.RepairRepository.Add(entity);
         _bheUOW.SaveChanges();
         return(entity.Id);
     }
     catch (Exception ex)
     {
         ExceptionHandler exceptionHandler = new ExceptionHandler();
         exceptionHandler.WrapLogException(ex);
         throw ex;
     }
 }
 public long Add(InvoiceDTO invoiceDTO)
 {
     try
     {
         long invoiceID = 0;
         mapper = new InvoiceMapper();
         if (invoiceDTO.SubmitingMode == "Update")
         {
         }
         else
         {
             invoiceID = _bheUOW.InvoiceRepository.Add(mapper.InvoiceEntityMapper(invoiceDTO));
         }
         _bheUOW.SaveChanges();
         return(invoiceID);
     }
     catch (Exception ex)
     {
         ExceptionHandler exceptionHandler = new ExceptionHandler();
         exceptionHandler.WrapLogException(ex);
         throw ex;
     }
 }