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

            try
            {
                ObjectValidator.IsValid(changeover);
                Changeover ch = new Changeover();
                ch.ChangeoverDateID       = changeover.DateID;
                ch.ChangeoverVehicleID    = changeover.VehicleID;
                ch.ChangeoverWorkTypeID   = changeover.WorkTypeID;
                ch.ChangeoverDescription  = String.IsNullOrWhiteSpace(changeover.Description) ? null : changeover.Description;
                ch.ChangeoverDetachmentID = changeover.DetachmentID;
                unitOfWork.BeginTransaction();
                repository.Add(ch);
                unitOfWork.CommitTransaction();
                return(ch.ChangeoverID);
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }
Ejemplo n.º 2
0
        public void UpdateChangeover(Objects.Changeover changeover)
        {
            IUnitOfWork unitOfWork = SessionFactory.GetUnitOfWork;
            IRepository <Changeover> repository = new Repositor <Changeover>(unitOfWork);

            try
            {
                ObjectValidator.IsValid(changeover);
                unitOfWork.BeginTransaction();
                var ch = repository.Single(c => c.ChangeoverID == changeover.ID);
                ch.ChangeoverDescription = String.IsNullOrWhiteSpace(changeover.Description) ? null : changeover.Description;
                repository.Update(ch);
                unitOfWork.CommitTransaction();
            }
            catch (Exception e)
            {
                unitOfWork.RollbackTransaction();
                throw new FaultException <WcfException>(ExceptionProvider.CreateFaultContract(e));
            }
        }