public AppUserViewModel GetViewModelForCreate()
        {
            var viewModel = new AppUserViewModel();

            viewModel.SystemUsers = this.SystemUserRepository.GetAll().ToArray();

            return viewModel;
        }
        public AppUserViewModel GetViewModelForCreate(AppUserViewModel oldViewModel)
        {
            var viewModel = new AppUserViewModel();

            viewModel.Code = oldViewModel.Code;
            viewModel.Name = oldViewModel.Name;
            viewModel.SystemUserID = oldViewModel.SystemUserID;
            viewModel.SystemUsers = oldViewModel.SystemUsers;
            viewModel.Timestamp = oldViewModel.Timestamp;

            return viewModel;
        }
        public void CreateEntity(AppUserViewModel viewModel)
        {
            var entity = this.AppUserRepository.Create();

            entity.ID = Guid.NewGuid();
            entity.Code = viewModel.Code;
            entity.Name = viewModel.Name;
            entity.SystemUserID = viewModel.SystemUserID;
            entity.Timestamp = viewModel.Timestamp;

            this.AppUserRepository.Add(entity);
            this.AppUserRepository.SaveChanges();
        }
        public AppUserViewModel GetViewModelForEdit(Guid id)
        {
            var viewModel = new AppUserViewModel();

            var entity = this.AppUserRepository.GetByID(id);
            viewModel.ID = entity.ID;
            viewModel.Code = entity.Code;
            viewModel.Name = entity.Name;
            viewModel.SystemUserID = entity.SystemUserID;
            viewModel.Timestamp = entity.Timestamp;
            viewModel.SystemUsers = this.SystemUserRepository.GetAll().ToArray();
            viewModel.IsNew = false;

            return viewModel;
        }
 private void CheckConcurrency(AppUserViewModel viewModel, M_AppUser entity)
 {
     if (!entity.Timestamp.SequenceEqual(viewModel.Timestamp))
     {
         throw new DbUpdateConcurrencyException();
     }
 }
        public void UpdateEntity(AppUserViewModel viewModel)
        {
            var entity = this.AppUserRepository.GetByID(viewModel.ID);

            this.CheckConcurrency(viewModel, entity);

            entity.Code = viewModel.Code;
            entity.Name = viewModel.Name;
            entity.SystemUserID = viewModel.SystemUserID;

            this.AppUserRepository.SaveChanges();
        }
        public void RemoveEntity(AppUserViewModel viewModel)
        {
            var entity = this.AppUserRepository.GetByID(viewModel.ID);

            this.CheckConcurrency(viewModel, entity);

            this.AppUserRepository.Remove(entity);
            this.AppUserRepository.SaveChanges();
        }
        public AppUserViewModel GetViewModelForEdit(AppUserViewModel oldViewModel)
        {
            var viewModel = new AppUserViewModel();

            viewModel.ID = oldViewModel.ID;
            viewModel.Code = oldViewModel.Code;
            viewModel.Name = oldViewModel.Name;
            viewModel.SystemUserID = oldViewModel.SystemUserID;
            viewModel.Timestamp = oldViewModel.Timestamp;
            viewModel.SystemUsers = oldViewModel.SystemUsers;
            viewModel.IsNew = false;

            return viewModel;
        }