public Validation CreateEvent(ref Event auctionEvent,
                                      long currentUserId)
        {
            var val = new Validation();

            var trans = _factory.BuildTransaction("CreateEvent");

            try
            {
                val = _validator.ValidateNewEvent(auctionEvent, ref trans);
                if (val.IsValid)
                {
                    auctionEvent.CreatedBy = currentUserId;
                    _repo.Insert(ref auctionEvent, ref trans);
                }
                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to create auction: {0}", e.Message));
            }
            finally
            {
                trans.Dispose();
            }

            return val;
        }
        public Validation ValidateExistingEvent(Event auctionEvent, ref IAuctionTransaction trans)
        {
            var val = new Validation();

            if (auctionEvent.Id <= 0)
            {
                val.AddError("Auction must have an id");
            }
            if (auctionEvent.Name == string.Empty)
            {
                val.AddError("Name is empty");
            }

            if (auctionEvent.Date == DateTime.MinValue)
            {
                val.AddError("Date is not set");
            }

            return val;
        }
        public Validation ValidateNewEvent(Event auctionEvent, ref IAuctionTransaction trans)
        {
            var val = new Validation();

            if (String.IsNullOrEmpty(auctionEvent.Name))
            {
                val.AddError("Name is empty");
            }

            if(auctionEvent.Date == DateTime.MinValue)
            {
                val.AddError("Date is not set");
            }

            int accountLimit = _accountRepo.GetAllowableEventCount(auctionEvent.AccountId, ref trans);
            int currentEventCount = _eventRepo.GetCountByAccount(auctionEvent.AccountId, ref trans);

            if(currentEventCount + 1 > accountLimit)
            {
                val.AddError("Account has reached maximum number of licensed events");
            }

            return val;
        }