示例#1
0
        public RemovedCustomer GetRemovedCustomer(Guid removedCustomerId)
        {
            RemovedCustomer removedCustomer        = null;
            var             dbRemovedCustomerFound = new DataContext().DbRemovedCustomers.FirstOrDefault(dbRemovedCustomer => dbRemovedCustomer.DbRemovedCustomerId == removedCustomerId);

            if (dbRemovedCustomerFound != null)
            {
                removedCustomer = new RemovedCustomer(dbRemovedCustomerFound);
            }

            return(removedCustomer);
        }
示例#2
0
        public RemovedCustomer RemoveCustomer(RemovedCustomer removedCustomer)
        {
            var dbContext = new DataContext();

            var dbRemovedCustomerFound = dbContext.DbRemovedCustomers.FirstOrDefault(dbRemovedCustomer => dbRemovedCustomer.DbCustomer.DbCustomerId == removedCustomer.Customer.CustomerId);

            if (dbRemovedCustomerFound == null)
            {
                dbRemovedCustomerFound                     = new DbRemovedCustomer();
                dbRemovedCustomerFound.DateRemoved         = removedCustomer.DateRemoved;
                dbRemovedCustomerFound.DbRemovedCustomerId = removedCustomer.RemovedCustomerId;
                dbRemovedCustomerFound.DbCustomer          = GetDbCustomer(dbContext, removedCustomer.Customer.CustomerId);
                dbRemovedCustomerFound.DbRemovedByUser     = new UsersRepository().GetDbUser(dbContext, removedCustomer.RemovedByUser.UserId);

                dbRemovedCustomerFound = dbContext.DbRemovedCustomers.Add(dbRemovedCustomerFound);
                dbContext.SaveChanges();
            }


            return(new RemovedCustomer(dbRemovedCustomerFound));
        }