Ejemplo n.º 1
0
        /// <summary>
        /// Delete the With Attach Entiy.
        /// </summary>
        /// <param name="Entiy">The Entiy.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        public bool DeleteWithAttachEntiy(EmployeeDto t)
        {
            var dbEntity = typeAdapter.ConvertDtoToEntities(t);

            entiesrepository.Attach(dbEntity);
            entiesrepository.Delete(dbEntity);
            entiesrepository.Save();
            return(true);
        }
Ejemplo n.º 2
0
        public void ShowManageVideoWalls()
        {
            IManageVideoWallsView view = new ManageVideoWallsForm();

            _employeeRepository.Attach(view);
            _videoWallRepository.Attach(view);

            _videoWallController.ManageVideoWalls(view, _videoWallRepository, this);

            _employeeRepository.Delete(view);
            _videoWallRepository.Delete(view);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the employee
        /// </summary>
        /// <param name="employee">
        /// The employee.
        /// </param>
        /// <returns>
        /// The update employee 2.
        /// </returns>
        /// <remarks>
        /// For WCF,because wcf cannot persistent ef4 objectcontext
        /// we also need change entity state then save it. Reference book 'Programming Entity framework 4'
        /// </remarks>
        public bool UpdateEmployeeByAttachEntity(Employee employee)
        {
            IObjectContext     context          = RepositoryHelper.GetDbContext();
            IUnitOfWork        uow              = RepositoryHelper.GetUnitOfWork(context);
            EmployeeRepository employRepository = RepositoryHelper.GetEmployeeRepository(context);

            employRepository.Attach(employee);
            employee.rowguid = System.Guid.NewGuid();
            employee.State   = State.Modified;
            //To avoid this error when update record
            // "The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated."
            // exec sp_executesql N'update [HumanResources].[Employee]
            employee.ModifiedDate = System.DateTime.Now;
            context.ChangeObjectState(employee, StateHelpers.GetEquivalentEntityState(employee.State));
            uow.Save();

            return(true);
        }