Ejemplo n.º 1
0
        public Objects.Detachment FindDetachment(Int32 detachmentID)
        {
            IUnitOfWork unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <Detachment> repository = new Repositor <Detachment>(unitOfWork);

            try
            {
                var d = repository.Single(c => c.DetachmentID == detachmentID);
                Objects.Detachment detachment = new Objects.Detachment();
                detachment.ID          = d.DetachmentID;
                detachment.Name        = d.DetachmentName;
                detachment.Description = d.DetachmentDescription;
                return(detachment);
            }
            catch (Exception e)
            {
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }
Ejemplo n.º 2
0
        public void UpdateDetachment(Objects.Detachment detachment)
        {
            IUnitOfWork unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <Detachment> repository = new Repositor <Detachment>(unitOfWork);

            try
            {
                ObjectValidator.IsValid(detachment);
                unitOfWork.BeginTransaction();
                var d = repository.Single(c => c.DetachmentID == detachment.ID);
                d.DetachmentDescription = String.IsNullOrWhiteSpace(detachment.Description) ? null : detachment.Description;
                repository.Update(d);
                unitOfWork.CommitTransaction();
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }
Ejemplo n.º 3
0
        public Int32 AddDetachment(Objects.Detachment detachment)
        {
            IUnitOfWork unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <Detachment> repository = new Repositor <Detachment>(unitOfWork);

            try
            {
                ObjectValidator.IsValid(detachment);
                Detachment d = new Detachment();
                d.DetachmentName        = String.IsNullOrWhiteSpace(detachment.Name) ? null : detachment.Name;
                d.DetachmentDescription = String.IsNullOrWhiteSpace(detachment.Description) ? null : detachment.Description;
                unitOfWork.BeginTransaction();
                repository.Add(d);
                unitOfWork.CommitTransaction();
                return(d.DetachmentID);
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }