예제 #1
0
        public void UpdateTour(Objects.Tour tour)
        {
            IUnitOfWork        unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <Tour> repository = new Repositor <Tour>(unitOfWork);

            try
            {
                ObjectValidator.IsValid(tour);
                unitOfWork.BeginTransaction();
                var t = repository.Single(c => c.TourID == tour.ID);
                t.TourDescription = String.IsNullOrWhiteSpace(tour.Description) ? null : tour.Description;
                repository.Update(t);
                unitOfWork.CommitTransaction();
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }
예제 #2
0
        public Int32 AddTour(Objects.Tour tour)
        {
            IUnitOfWork        unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <Tour> repository = new Repositor <Tour>(unitOfWork);

            try
            {
                ObjectValidator.IsValid(tour);
                Tour t = new Tour();
                t.TourStartTime    = tour.StartTime;
                t.TourEndTime      = tour.EndTime;
                t.TourDetachmentID = tour.DetachmentID;
                t.TourDescription  = String.IsNullOrWhiteSpace(tour.Description) ? null : tour.Description;
                unitOfWork.BeginTransaction();
                repository.Add(t);
                unitOfWork.CommitTransaction();
                return(t.TourID);
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }