private void LoadUserData() { TracktorDb context = new TracktorDb(); UserRepository userRepo = new UserRepository(context); List <UserEntity> users = userRepo.GetAll().ToList(); AllUsers = new BindingList <UserEntity>(users); }
private void LoadCommentData() { TracktorDb context = new TracktorDb(); CommentRepository commentRepo = new CommentRepository(context); List <CommentEntity> comments = commentRepo.GetAll().ToList(); AllComments = new BindingList <CommentEntity>(comments); }
private void LoadPlaceData() { TracktorDb context = new TracktorDb(); PlaceRepository placeRepo = new PlaceRepository(context); List <PlaceEntity> places = placeRepo.GetAll().ToList(); AllPlaces = new BindingList <PlaceEntity>(places); }
private void LoadUserTypeData() { TracktorDb context = new TracktorDb(); UserTypeRepository UserTypeRepo = new UserTypeRepository(context); List <UserTypeEntity> UserTypes = UserTypeRepo.GetAll().ToList(); AllUserTypes = new BindingList <UserTypeEntity>(UserTypes); }
public static IInfoServices getInfoServices(TracktorDb context = null) { if (context != null) { return(new InfoServices(context)); } return(new InfoServices()); }
public static IPlaceServices getPlaceServices(TracktorDb context = null) { if (context != null) { return(new PlaceServices(context)); } return(new PlaceServices()); }
public static ICommentServices getCommentServices(TracktorDb context = null) { if (context != null) { return(new CommentServices(context)); } return(new CommentServices()); }
public static ICategoryServices getCategoryServices(TracktorDb context = null) { if (context != null) { return(new CategoryServices(context)); } return(new CategoryServices()); }
public static IUserTypeServices getUserTypeServices(TracktorDb context = null) { if (context != null) { return(new UserTypeServices(context)); } return(new UserTypeServices()); }
private void LoadInfoData() { TracktorDb context = new TracktorDb(); InfoRepository infoRepo = new InfoRepository(context); List <InfoEntity> infos = infoRepo.GetAll().ToList(); AllInfos = new BindingList <InfoEntity>(infos); }
private void LoadCategoryData() { TracktorDb context = new TracktorDb(); CategoryRepository catRepo = new CategoryRepository(context); List <CategoryEntity> cats = catRepo.GetAll().ToList(); AllCategories = new BindingList <CategoryEntity>(cats); }
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; } }
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 }
public UnitOfWork(TracktorDb context = null) { if (context == null) { _context = new TracktorDb(); } else { _context = context; } }
public PlaceServices(TracktorDb context = null) { if (context != null) { _unitOfWork = new UnitOfWork(context); } else { _unitOfWork = new UnitOfWork(); } }
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 }
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 }
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 }
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 }
/// <summary> /// Public Constructor,initializes privately declared local variables. /// </summary> /// <param name="context"></param> public CategoryRepository(TracktorDb context) : base(context) { }
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 }
/// <summary> /// Public Constructor,initializes privately declared local variables. /// </summary> /// <param name="context"></param> public UserTypeRepository(TracktorDb context) : base(context) { }
/// <summary> /// Public Constructor,initializes privately declared local variables. /// </summary> /// <param name="context"></param> public ReputationCommentRepository(TracktorDb context) : base(context) { }
/// <summary> /// Public Constructor,initializes privately declared local variables. /// </summary> /// <param name="context"></param> public ReputationInfoRepository(TracktorDb context) : base(context) { }
/// <summary> /// Public Constructor,initializes privately declared local variables. /// </summary> /// <param name="context"></param> public CommentRepository(TracktorDb context) : base(context) { }
/// <summary> /// Public Constructor,initializes privately declared local variables. /// </summary> /// <param name="context"></param> public InfoRepository(TracktorDb context) : base(context) { }
/// <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>(); }
/// <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(); }
/// <summary> /// Public Constructor,initializes privately declared local variables. /// </summary> /// <param name="context"></param> public PlaceRepository(TracktorDb context) : base(context) { }