public static void SetTargetTime(this DivisionType divisionType, ref DateTime targetTime1, ref DateTime targetTime2) { switch (divisionType) { case DivisionType.Year: targetTime1 = DateTime.Parse(targetTime1.ToString("yyyy-01-01")); targetTime2 = DateTime.Parse(targetTime2.ToString("yyyy-01-01")).AddYears(1).AddSeconds(-1); break; case DivisionType.Month: targetTime1 = DateTime.Parse(targetTime1.ToString("yyyy-MM-01")); targetTime2 = DateTime.Parse(targetTime2.ToString("yyyy-MM-01")).AddMonths(1).AddSeconds(-1); break; case DivisionType.Day: targetTime1 = DateTime.Parse(targetTime1.ToString("yyyy-MM-dd")); targetTime2 = DateTime.Parse(targetTime2.ToString("yyyy-MM-dd")).AddDays(1).AddSeconds(-1); break; case DivisionType.Hour: targetTime1 = DateTime.Parse(targetTime1.ToString("yyyy-MM-dd HH:00:00")); targetTime2 = DateTime.Parse(targetTime2.ToString("yyyy-MM-dd HH:00:00")).AddHours(1).AddSeconds(-1); break; default: break; } }
void buttonSave_Click(object sender, EventArgs e) { try { Page.Validate(); if (Page.IsValid) { DivisionType team = DivisionTypeBL.GetBy(base.DivisionTypeId, false); if (team == null) { // insert team = new DivisionType(); team.Name = TextName.Text; team.LeagueId = base.LeagueId; team.Description = TextDescription.Text; team = DivisionTypeBL.Insert(team); } else { // update team.Name = TextName.Text; team.Description = TextDescription.Text; team = DivisionTypeBL.Update(team); } if (team == null) { message.Text = "Save failed"; } else { _redirectToListUrl(); } } } catch (Exception ex) { message.Text = ex.Message; } }
public async Task <Division> Create(int directorUserId, string fiasId, DivisionType divisionType, string name, int?parentDivisionId) { var director = await GetAndCheckDirectorUser(directorUserId); var fiasAddress = await _daDataService.GetAddressByFiasId(fiasId); fiasAddress = await _addressService.Create(fiasAddress); var division = new Division() { DirectorUserId = director.Id, Name = name, AddressId = fiasAddress.Id, DivisionType = divisionType, ParentDivisionId = parentDivisionId }; _context.Divisions.Add(division); await _context.SaveChangesAsync(); return(division); }
public void ReturnDivisionTypeWithProvidedId() { //Arrange Guid id = Guid.NewGuid(); DivisionType expectedDivisionType = new DivisionType() { Id = id, Name = "Test", Description = "Test" }; var divisionTypeDbSetMock = QueryableDbSetMock.GetQueryableMockDbSet(new List <DivisionType>() { expectedDivisionType }); divisionTypeDbSetMock.Setup(x => x.Find(expectedDivisionType.Id)).Returns(expectedDivisionType); var yoyoTournamentsDbContextMock = new Mock <IYoyoTournamentsDbContext>(); yoyoTournamentsDbContextMock.Setup(x => x.DivisionTypes).Returns(divisionTypeDbSetMock.Object); var divisionTypeService = new DivisionTypeService(yoyoTournamentsDbContextMock.Object); //Act var actualDivisionType = divisionTypeService.GetDivisionTypeById(id); //Assert Assert.AreSame(expectedDivisionType, actualDivisionType); }
public void ReturnNull_WhenDivisionTypeWithIdIsNotFound() { //Arrange Guid id = Guid.NewGuid(); DivisionType divisionType = new DivisionType() { Id = id, Name = "Test", Description = "Test" }; var divisionTypeDbSetMock = QueryableDbSetMock.GetQueryableMockDbSet(new List <DivisionType>() { divisionType }); divisionTypeDbSetMock.Setup(x => x.Find(Guid.NewGuid())).Returns((DivisionType)null); var yoyoTournamentsDbContextMock = new Mock <IYoyoTournamentsDbContext>(); yoyoTournamentsDbContextMock.Setup(x => x.DivisionTypes).Returns(divisionTypeDbSetMock.Object); var divisionTypeService = new DivisionTypeService(yoyoTournamentsDbContextMock.Object); //Act var actualDivisionType = divisionTypeService.GetDivisionTypeById(id); //Assert Assert.IsNull(actualDivisionType); }
public Duration() { Value = Quarter; IsDotted = false; IsDoubleDotted = false; Division = new DivisionType(); }
public MinorLeagueDivision(string url, int uLevel, Gender gender, string name, DivisionType divisionType) { Url = url; ULevel = uLevel; Gender = gender; Name = name; DivisionType = divisionType; }
public DivisionInfoModel(DivisionInfoModel division) { _divisionInfoId = division.DivisionInfoId; _name = division.Name; _description = division.Description; _divisionType = division.DivisionType; _machinePath = division.MachinePath; }
private static DivisionType NewDivisionType(int enters, int times) { DivisionType divisionType = new DivisionType(); divisionType.Enters = enters; divisionType.Times = times; return(divisionType); }
public DivisionType Insert(DivisionType divisionType) { divisionType.Enabled = true; divisionType.ID = Guid.NewGuid(); divisionType.Created = DateTime.Now; divisionType.Modified = DateTime.Now; DataContextHelper.CurrentContext.DivisionTypes.InsertOnSubmit(divisionType); DataContextHelper.CurrentContext.SubmitChanges(); return divisionType; }
public static EquationBase CreateEquation(EquationContainer equationParent, DivisionType divType) { EquationBase equation = null; switch (divType) { case DivisionType.DivRegular: equation = new DivRegular(equationParent); break; case DivisionType.DivRegularSmall: equation = new DivRegularSmall(equationParent); break; case DivisionType.DivDoubleBar: equation = new DivDoubleBar(equationParent); break; case DivisionType.DivTripleBar: equation = new DivTripleBar(equationParent); break; case DivisionType.DivHoriz: equation = new DivHorizontal(equationParent); break; case DivisionType.DivHorizSmall: equation = new DivHorizSmall(equationParent); break; case DivisionType.DivMath: equation = new DivMath(equationParent); break; case DivisionType.DivMathWithTop: equation = new DivMathWithTop(equationParent); break; case DivisionType.DivSlanted: equation = new DivSlanted(equationParent); break; case DivisionType.DivSlantedSmall: equation = new DivSlantedSmall(equationParent); break; case DivisionType.DivMathInverted: equation = new DivMathInverted(equationParent); break; case DivisionType.DivInvertedWithBottom: equation = new DivMathWithBottom(equationParent); break; case DivisionType.DivTriangleFixed: equation = new DivTriangle(equationParent, true); break; case DivisionType.DivTriangleExpanding: equation = new DivTriangle(equationParent, false); break; } return equation; }
public DivisionType GetDivisionTypeById(Guid id) { DivisionType result = null; if (id != null) { result = this.dbContext.DivisionTypes .Find(id); } return(result); }
public DivisionType Update(DivisionType divisionType) { DivisionType value = DataContextHelper.CurrentContext.DivisionTypes.FirstOrDefault<DivisionType>(n => n.ID.Equals(divisionType.ID)); if (value != null) { value.Name = divisionType.Name.Trim(); value.Description = divisionType.Description.Trim(); value.Enabled = divisionType.Enabled; value.Modified = DateTime.Now; DataContextHelper.CurrentContext.SubmitChanges(); } return value; }
public static void PlusTargetTime(this DivisionType divisionType, ref DateTime targetTime) { switch (divisionType) { case DivisionType.Year: targetTime = targetTime.AddYears(1); break; case DivisionType.Month: targetTime = targetTime.AddMonths(1); break; case DivisionType.Day: targetTime = targetTime.AddDays(1); break; case DivisionType.Hour: targetTime = targetTime.AddHours(1); break; default: break; } }
public void ReturnDetailsWithDivisionTypeDetailsViewModel() { // Arrange var expectedDivisionType = new DivisionType { Id = Guid.NewGuid(), Name = "Test", Description = "Test description" }; var divisionTypeServiceMock = new Mock <IDivisionTypeService>(); divisionTypeServiceMock .Setup(x => x.GetDivisionTypeById(expectedDivisionType.Id)) .Returns(expectedDivisionType); var controller = new DivisionTypeController(divisionTypeServiceMock.Object); // Act & Assert controller .WithCallTo(x => x.Details(expectedDivisionType.Id)) .ShouldRenderDefaultView() .WithModel <DivisionTypeDetailsViewModel>(); }
public void CallGetDivisionTypeByIdOnce() { // Arrange var expectedDivisionType = new DivisionType { Id = Guid.NewGuid(), Name = "Test", Description = "Test description" }; var divisionTypeServiceMock = new Mock <IDivisionTypeService>(); divisionTypeServiceMock .Setup(x => x.GetDivisionTypeById(expectedDivisionType.Id)) .Returns(expectedDivisionType); var controller = new DivisionTypeController(divisionTypeServiceMock.Object); // Act controller.Details(expectedDivisionType.Id); // Assert divisionTypeServiceMock.Verify(x => x.GetDivisionTypeById(expectedDivisionType.Id), Times.Once); }
public void ReturnOneDivision() { //Arrange DivisionType divisionType = new DivisionType() { Name = "Test", Description = "Test" }; var divisionTypeDbSetMock = QueryableDbSetMock.GetQueryableMockDbSet(new List <DivisionType>() { divisionType }); var yoyoTournamentsDbContextMock = new Mock <IYoyoTournamentsDbContext>(); yoyoTournamentsDbContextMock.Setup(x => x.DivisionTypes).Returns(divisionTypeDbSetMock.Object); var divisionTypeService = new DivisionTypeService(yoyoTournamentsDbContextMock.Object); //Act var result = divisionTypeService.GetAllDivisionTypes().ToList(); //Assert Assert.AreEqual(1, result.Count); }
private void detach_DivisionTypes(DivisionType entity) { this.SendPropertyChanging(); entity.League = null; }
public void AddDivision(DivisionType division) { throw new NotImplementedException(); }
partial void UpdateDivisionType(DivisionType instance);
public static EquationBase CreateEquation(EquationContainer equationParent, DivisionType divType) { EquationBase equation = null; switch (divType) { case DivisionType.DivRegular: equation = new DivRegular(equationParent); break; case DivisionType.DivRegularSmall: equation = new DivRegularSmall(equationParent); break; case DivisionType.DivDoubleBar: equation = new DivDoubleBar(equationParent); break; case DivisionType.DivTripleBar: equation = new DivTripleBar(equationParent); break; case DivisionType.DivHoriz: equation = new DivHorizontal(equationParent); break; case DivisionType.DivHorizSmall: equation = new DivHorizSmall(equationParent); break; case DivisionType.DivMath: equation = new DivMath(equationParent); break; case DivisionType.DivMathWithTop: equation = new DivMathWithTop(equationParent); break; case DivisionType.DivSlanted: equation = new DivSlanted(equationParent); break; case DivisionType.DivSlantedSmall: equation = new DivSlantedSmall(equationParent); break; case DivisionType.DivMathInverted: equation = new DivMathInverted(equationParent); break; case DivisionType.DivInvertedWithBottom: equation = new DivMathWithBottom(equationParent); break; case DivisionType.DivTriangleFixed: equation = new DivTriangle(equationParent, true); break; case DivisionType.DivTriangleExpanding: equation = new DivTriangle(equationParent, false); break; } return(equation); }
public static bool IsAllowed(DivisionType division, Object parent) { //for now, only plain coa are available return parent is CoatOfArms && division == DivisionType.PartyPlain; }
public async Task <Division> GetDivision(DivisionType divisionType) { var json = await File.ReadAllTextAsync($"SeedData\\{divisionType}SeedData.json"); return(await Task.Run(() => JsonConvert.DeserializeObject <Division>(json))); }
partial void DeleteDivisionType(DivisionType instance);
public Divisions(int divisionNumber, DivisionType divisionType) { this.divisionNumber = divisionNumber; this.divisionType = divisionType; }
public async Task <ActionResult <LeagueOverview> > GetMinorLeague(string competition, Gender gender, DivisionType division) { try { if (!int.TryParse(competition.TrimStart('u', 'U'), out int uRating)) { return(BadRequest($"Invalid U rating")); } var topLevel = await kzsParser.GetTopLevelAsync(CancellationToken.None); var query = from ml in topLevel.MinorLeagues where ml.ULevel == uRating && ml.Gender == gender from d in ml.Divisions where d.DivisionType == division select d; var current = query.SingleOrDefault(); if (current == null) { return(NotFound()); } var result = await cacheService.GetDataAsync( current.Url, TimeSpan.FromMinutes(15), (k, ct) => kzsParser.GetLeagueOverviewAsync(k, areStandingRequired: true, ct), CancellationToken.None); return(result); } catch (DomParsingException) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public static DivisionType Update(DivisionType divisionType) { return new DivisionTypeDao().Update(divisionType); }
public static BarResultRequest BarResultRequest(BarResultType resultType = BarResultType.BarForce, DivisionType divisionType = DivisionType.EvenlyDistributed, int divisions = 5, List <object> cases = null, List <string> modes = null, List <object> objectIds = null) { return(new BarResultRequest { ResultType = resultType, DivisionType = divisionType, Divisions = divisions, Cases = cases ?? new List <object>(), Modes = modes ?? new List <string>(), ObjectIds = objectIds ?? new List <object>() }); }
public static DivisionType Insert(DivisionType divisionType) { return new DivisionTypeDao().Insert(divisionType); }
public string ConvertsCorrectly(DivisionType division) { return((string)Target.ConvertTo(division, typeof(string))); }
public static void Delete(DivisionType divisionType) { new DivisionTypeDao().Delete(divisionType); }
public void Delete(DivisionType divisionType) { DataContextHelper.CurrentContext.DivisionTypes.DeleteOnSubmit(divisionType); DataContextHelper.CurrentContext.SubmitChanges(); }
partial void InsertDivisionType(DivisionType instance);