Пример #1
0
        public void UpdateWorkerState(Objects.WorkerState workerState)
        {
            IUnitOfWork unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <WorkerState> repository = new Repositor <WorkerState>(unitOfWork);

            try
            {
                ObjectValidator.IsValid(workerState);
                unitOfWork.BeginTransaction();
                var ws = repository.Single(c => c.WorkerStateID == workerState.ID);
                ws.WorkerStateDescription = String.IsNullOrWhiteSpace(workerState.Description) ? null : workerState.Description;
                repository.Update(ws);
                unitOfWork.CommitTransaction();
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }
Пример #2
0
        public Int32 AddWorkerState(Objects.WorkerState workerState)
        {
            IUnitOfWork unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <WorkerState> repository = new Repositor <WorkerState>(unitOfWork);

            try
            {
                ObjectValidator.IsValid(workerState);
                WorkerState ws = new WorkerState();
                ws.WorkerStateName         = String.IsNullOrWhiteSpace(workerState.Name) ? null : workerState.Name;
                ws.WorkerStateDescription  = String.IsNullOrWhiteSpace(workerState.Description) ? null : workerState.Description;
                ws.WorkerStateDetachmentID = workerState.DetachmentID;
                unitOfWork.BeginTransaction();
                repository.Add(ws);
                unitOfWork.CommitTransaction();
                return(ws.WorkerStateID);
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }