コード例 #1
0
        private void LoadUserData()
        {
            TracktorDb        context  = new TracktorDb();
            UserRepository    userRepo = new UserRepository(context);
            List <UserEntity> users    = userRepo.GetAll().ToList();

            AllUsers = new BindingList <UserEntity>(users);
        }
コード例 #2
0
        private void LoadCommentData()
        {
            TracktorDb           context     = new TracktorDb();
            CommentRepository    commentRepo = new CommentRepository(context);
            List <CommentEntity> comments    = commentRepo.GetAll().ToList();

            AllComments = new BindingList <CommentEntity>(comments);
        }
コード例 #3
0
        private void LoadPlaceData()
        {
            TracktorDb         context   = new TracktorDb();
            PlaceRepository    placeRepo = new PlaceRepository(context);
            List <PlaceEntity> places    = placeRepo.GetAll().ToList();

            AllPlaces = new BindingList <PlaceEntity>(places);
        }
コード例 #4
0
        private void LoadUserTypeData()
        {
            TracktorDb            context      = new TracktorDb();
            UserTypeRepository    UserTypeRepo = new UserTypeRepository(context);
            List <UserTypeEntity> UserTypes    = UserTypeRepo.GetAll().ToList();

            AllUserTypes = new BindingList <UserTypeEntity>(UserTypes);
        }
コード例 #5
0
 public static IInfoServices getInfoServices(TracktorDb context = null)
 {
     if (context != null)
     {
         return(new InfoServices(context));
     }
     return(new InfoServices());
 }
コード例 #6
0
 public static IPlaceServices getPlaceServices(TracktorDb context = null)
 {
     if (context != null)
     {
         return(new PlaceServices(context));
     }
     return(new PlaceServices());
 }
コード例 #7
0
 public static ICommentServices getCommentServices(TracktorDb context = null)
 {
     if (context != null)
     {
         return(new CommentServices(context));
     }
     return(new CommentServices());
 }
コード例 #8
0
 public static ICategoryServices getCategoryServices(TracktorDb context = null)
 {
     if (context != null)
     {
         return(new CategoryServices(context));
     }
     return(new CategoryServices());
 }
コード例 #9
0
 public static IUserTypeServices getUserTypeServices(TracktorDb context = null)
 {
     if (context != null)
     {
         return(new UserTypeServices(context));
     }
     return(new UserTypeServices());
 }
コード例 #10
0
        private void LoadInfoData()
        {
            TracktorDb        context  = new TracktorDb();
            InfoRepository    infoRepo = new InfoRepository(context);
            List <InfoEntity> infos    = infoRepo.GetAll().ToList();

            AllInfos = new BindingList <InfoEntity>(infos);
        }
コード例 #11
0
        private void LoadCategoryData()
        {
            TracktorDb            context = new TracktorDb();
            CategoryRepository    catRepo = new CategoryRepository(context);
            List <CategoryEntity> cats    = catRepo.GetAll().ToList();

            AllCategories = new BindingList <CategoryEntity>(cats);
        }
コード例 #12
0
ファイル: PestForm.cs プロジェクト: mherceg/oobl-seminar
        private void btnPestYes_Click(object sender, EventArgs e)
        {
            TracktorDb context = new TracktorDb();
            UnitOfWork _unitOfWork;

            if (logout)
            {
                this.Close();
            }

            if (context != null)
            {
                _unitOfWork = new UnitOfWork(context);
            }
            else
            {
                _unitOfWork = new UnitOfWork();
            }

            if (user != null)
            {
                _unitOfWork.UserRepository.Remove(user.Id, _unitOfWork.Save);
                return;
            }

            if (ut != null)
            {
                _unitOfWork.UserTypeRepository.Delete(ut.Id, _unitOfWork.Save);
                return;
            }

            if (info != null)
            {
                _unitOfWork.InfoRepository.Remove(info, _unitOfWork.Save);
                return;
            }

            if (place != null)
            {
                _unitOfWork.PlaceRepository.Delete(place.Id, _unitOfWork.Save);
                return;
            }

            if (cat != null)
            {
                _unitOfWork.CategoryRepository.Delete(cat.Id, _unitOfWork.Save);
                return;
            }

            if (comment != null)
            {
                //var comServices = ServiceFactory.getCommentServices();
                //comServices.Delete(comment.Id);
                return;
            }
        }
コード例 #13
0
        private void btnInfoCrudOK_Click(object sender, EventArgs e)
        {
            #region Try to make changes
            if (readOnly)
            {
                this.Close();
            }

            if (!isEmpty())
            {
                #region Reading data from form

                info.content    = tbInfoCrudContent.Text;
                info.time       = dtpInfoCrudStartDate.Value.Date + dtpInfoCrudStartTime.Value.TimeOfDay;
                info.endTime    = dtpInfoCrudEndDate.Value.Date + dtpInfoCrudEndTime.Value.TimeOfDay;
                info.userId     = Convert.ToInt32(tbInfoCrudUID.Text);
                info.placeId    = Convert.ToInt32(tbInfoCrudPID.Text);
                info.categoryId = ((CategoryEntity)cbInfoCrudCategory.SelectedItem).Id;

                #endregion

                #region Database stuff
                TracktorDb context = new TracktorDb();
                UnitOfWork _unitOfWork;

                if (context != null)
                {
                    _unitOfWork = new UnitOfWork(context);
                }
                else
                {
                    _unitOfWork = new UnitOfWork();
                }

                try
                {
                    if (editing)
                    {
                        _unitOfWork.InfoRepository.Update(info, _unitOfWork.Save);
                    }
                    else
                    {
                        info.Id = _unitOfWork.InfoRepository.Insert(info, _unitOfWork.Save);
                    }
                } catch (Exception xce)
                {
                    this.lblInfoCrudError.Text    = "No such category!";
                    this.lblInfoCrudError.Visible = true;
                    return;
                }
                this.DialogResult = DialogResult.OK;
                #endregion
            }
            #endregion
        }
コード例 #14
0
 public UnitOfWork(TracktorDb context = null)
 {
     if (context == null)
     {
         _context = new TracktorDb();
     }
     else
     {
         _context = context;
     }
 }
コード例 #15
0
 public PlaceServices(TracktorDb context = null)
 {
     if (context != null)
     {
         _unitOfWork = new UnitOfWork(context);
     }
     else
     {
         _unitOfWork = new UnitOfWork();
     }
 }
コード例 #16
0
        private void btnUserCrudOK_Click(object sender, EventArgs e)
        {
            #region Try to make changes
            if (readOnly)
            {
                this.Close();
            }

            if (!isEmpty())
            {
                #region Reading data from form
                user.FullName = tbUserCrudFullName.Text;
                user.Username = tbUserCrudName.Text;
                user.IsActive = cbUserCrudActive.Checked;
                user.Password = tbUserCrudPass.Text;

                int i = 1;
                foreach (RadioButton radio in userType)
                {
                    if (radio.Checked == true)
                    {
                        user.UserTypeId = i;
                        break;
                    }
                    ++i;
                }
                #endregion

                #region Database stuff
                TracktorDb context = new TracktorDb();
                UnitOfWork _unitOfWork;

                if (context != null)
                {
                    _unitOfWork = new UnitOfWork(context);
                }
                else
                {
                    _unitOfWork = new UnitOfWork();
                }

                if (editing)
                {
                    _unitOfWork.UserRepository.Update(user, _unitOfWork.Save);
                }
                else
                {
                    user.Id = _unitOfWork.UserRepository.Insert(user, _unitOfWork.Save);
                }
                #endregion
            }
            #endregion
        }
コード例 #17
0
        private void btnCommentCrudOK_Click(object sender, EventArgs e)
        {
            #region Try to make changes
            if (readOnly)
            {
                this.Close();
            }

            if (!isEmpty())
            {
                #region Reading data from form

                comment.Content = tbCommentCrudContent.Text;

                #endregion

                #region Database stuff
                TracktorDb context = new TracktorDb();
                UnitOfWork _unitOfWork;

                if (context != null)
                {
                    _unitOfWork = new UnitOfWork(context);
                }
                else
                {
                    _unitOfWork = new UnitOfWork();
                }

                try {
                    if (editing)
                    {
                        _unitOfWork.CommentRepository.Update(comment, _unitOfWork.Save);
                    }
                    else
                    {
                        comment.Id = _unitOfWork.CommentRepository.Insert(comment, _unitOfWork.Save);
                    }
                } catch (Exception xce)
                {
                    this.lblCommentCrudError.Text    = "No such info!";
                    this.lblCommentCrudError.Visible = true;
                    return;
                }

                this.DialogResult = DialogResult.OK;
                #endregion
            }
            #endregion
        }
コード例 #18
0
        private void btnPlaceCrudOK_Click(object sender, EventArgs e)
        {
            #region Try to make changes
            if (readOnly)
            {
                this.Close();
            }

            if (!isEmpty())
            {
                #region Reading data from form

                place.Name     = tbPlaceCrudName.Text;
                place.Location = new GeoCoordinate(Convert.ToDouble(tbPlaceCrudLat.Text), Convert.ToDouble(tbPlaceCrudLon.Text));

                #endregion
                #region Database stuff
                TracktorDb context = new TracktorDb();
                UnitOfWork _unitOfWork;

                if (context != null)
                {
                    _unitOfWork = new UnitOfWork(context);
                }
                else
                {
                    _unitOfWork = new UnitOfWork();
                }

                if (editing)
                {
                    _unitOfWork.PlaceRepository.Update(place, _unitOfWork.Save);
                }
                else
                {
                    place.Id = _unitOfWork.PlaceRepository.Insert(place, _unitOfWork.Save);
                }
                #endregion
            }
            #endregion
        }
コード例 #19
0
ファイル: CRUD_UserType.cs プロジェクト: mherceg/oobl-seminar
        private void btnUTCrudOK_Click(object sender, EventArgs e)
        {
            #region Try to make changes
            if (readOnly)
            {
                this.Close();
            }

            if (!isEmpty())
            {
                #region Reading data from form

                ut.Type = tbUTCrudType.Text;

                #endregion

                #region Database stuff
                TracktorDb context = new TracktorDb();
                UnitOfWork _unitOfWork;

                if (context != null)
                {
                    _unitOfWork = new UnitOfWork(context);
                }
                else
                {
                    _unitOfWork = new UnitOfWork();
                }

                if (editing)
                {
                    _unitOfWork.UserTypeRepository.Update(ut, _unitOfWork.Save);
                }
                else
                {
                    ut.Id = _unitOfWork.UserTypeRepository.Insert(ut, _unitOfWork.Save);
                }
                #endregion
            }
            #endregion
        }
コード例 #20
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public CategoryRepository(TracktorDb context) : base(context)
 {
 }
コード例 #21
0
        public CRUD_Information(InfoEntity newInfo, int userId = 0)
        {
            InitializeComponent();
            readOnly = false;
            editing  = false;

            this.info = newInfo;

            TracktorDb                       context = new TracktorDb();
            CategoryRepository               catRepo = new CategoryRepository(context);
            List <CategoryEntity>            cats    = catRepo.GetAll().ToList();
            Dictionary <int, CategoryEntity> allCats = new Dictionary <int, CategoryEntity>();

            foreach (CategoryEntity categ in cats)
            {
                allCats.Add(categ.Id, categ);
                cbInfoCrudCategory.Items.Add(categ);
            }

            #region DateTimePicker formatting
            dtpInfoCrudStartDate.CustomFormat = "DD.MM.YYYY.";
            dtpInfoCrudEndDate.CustomFormat   = "DD.MM.YYYY.";
            dtpInfoCrudStartDate.MinDate      = Convert.ToDateTime("1.1.2000.").Date;
            dtpInfoCrudStartDate.MaxDate      = Convert.ToDateTime("31.12.9998.").Date;
            #endregion

            btnInfoCrudOK.DialogResult = DialogResult.None;
            //btnInfoCrudCancel.DialogResult = DialogResult.Cancel;
            btnInfoCrudCancel.DialogResult = DialogResult.None;

            #region Initialization

            if (info.Id != 0)
            {
                tbInfoCrudID.Text = info.Id.ToString();
            }
            else
            {
                tbInfoCrudID.Text = "";
            }

            if (info.userId != 0)
            {
                tbInfoCrudID.Text = info.Id.ToString();
            }
            else
            {
                tbInfoCrudUID.Text = userId.ToString();
            }

            SetTimeWithinRange();

            tbInfoCrudContent.Text     = info.content;
            dtpInfoCrudStartDate.Value = info.time.Date;
            dtpInfoCrudStartTime.Value = info.time;
            dtpInfoCrudEndDate.Value   = info.endTime.Date;
            dtpInfoCrudEndTime.Value   = info.endTime;
            tbInfoCrudUID.Text         = info.userId.ToString();
            tbInfoCrudPID.Text         = info.placeId.ToString();

            CategoryEntity cat;
            allCats.TryGetValue(info.categoryId, out cat);
            cbInfoCrudCategory.SelectedItem = cat;

            #endregion
        }
コード例 #22
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public UserTypeRepository(TracktorDb context) : base(context)
 {
 }
コード例 #23
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public ReputationCommentRepository(TracktorDb context) : base(context)
 {
 }
コード例 #24
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public ReputationInfoRepository(TracktorDb context) : base(context)
 {
 }
コード例 #25
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public CommentRepository(TracktorDb context) : base(context)
 {
 }
コード例 #26
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public InfoRepository(TracktorDb context) : base(context)
 {
 }
コード例 #27
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public GenericRepository(TracktorDb context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
 }
コード例 #28
0
ファイル: EFRepository.cs プロジェクト: mherceg/oobl-seminar
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public EFRepository(TracktorDb context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
     this.Mapper  = new ModelMapper();
 }
コード例 #29
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public PlaceRepository(TracktorDb context) : base(context)
 {
 }