public EditInvitationCommand( int invitationId, string title, string description, string location, DateTime startTime, DateTime endTime, DisciplineType type, IList <ParticipantsForEditCommand> updatedParticipants, IEnumerable <string> updatedMcPkgScope, IEnumerable <string> updatedCommPkgScope, string rowVersion) { InvitationId = invitationId; UpdatedMcPkgScope = updatedMcPkgScope?.ToList() ?? new List <string>(); UpdatedCommPkgScope = updatedCommPkgScope?.ToList() ?? new List <string>(); UpdatedParticipants = updatedParticipants; Description = description; Location = location; StartTime = startTime; EndTime = endTime; Type = type; Title = title; RowVersion = rowVersion; }
public static void CreateOrUpdateCompetitionDiscipline(Guid disciplinePKey, DisciplineType type, string name, string unit, bool lowIsBetter) { using (HonglornDb db = new HonglornDb()) { CompetitionDiscipline competition = db.CompetitionDiscipline.Find(disciplinePKey); if (competition == null) { // Create db.CompetitionDiscipline.Add(new CompetitionDiscipline { Type = type, Name = name, Unit = unit, LowIsBetter = lowIsBetter }); } else { // Update competition.Type = type; competition.Name = name; competition.Unit = unit; competition.LowIsBetter = lowIsBetter; } db.SaveChanges(); } }
public InvitationDto( string projectName, string title, string description, string location, DisciplineType type, IpoStatus status, PersonDto createdBy, DateTime startTimeUtc, DateTime endTimeUtc, bool canEdit, string rowVersion, bool canCancel, bool canDelete) { ProjectName = projectName; Title = title; Description = description; Location = location; Type = type; Status = status; CreatedBy = createdBy; StartTimeUtc = startTimeUtc; EndTimeUtc = endTimeUtc; CanEdit = canEdit; CanCancel = canCancel; CanDelete = canDelete; RowVersion = rowVersion; }
/// <summary> /// Updates or creates a resource based on the resource identifier. The PUT operation is used to update or create a resource by identifier. If the resource doesn't exist, the resource will be created using that identifier. Additionally, natural key values cannot be changed using this operation, and will not be modified in the database. If the resource "id" is provided in the JSON body, it will be ignored as well. /// </summary> /// <param name="id">A resource identifier specifying the resource to be updated.</param> /// <param name="IfMatch">The ETag header value used to prevent the PUT from updating a resource modified by another consumer.</param> /// <param name="body">The JSON representation of the "disciplineType" resource to be updated.</param> /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns> public IRestResponse PutDisciplineType(string id, string IfMatch, DisciplineType body) { var request = new RestRequest("/disciplineTypes/{id}", Method.PUT); request.RequestFormat = DataFormat.Json; request.AddUrlSegment("id", id); // verify required params are set if (id == null || body == null) { throw new ArgumentException("API method call is missing required parameters"); } request.AddHeader("If-Match", IfMatch); request.AddBody(body); request.Parameters.First(param => param.Type == ParameterType.RequestBody).Name = "application/json"; var response = client.Execute(request); var location = response.Headers.FirstOrDefault(x => x.Name == "Location"); if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString())) { body.id = location.Value.ToString().Split('/').Last(); } return(response); }
public CreateInvitationCommand( string title, string description, string location, DateTime startTime, DateTime endTime, string projectName, DisciplineType type, IList <ParticipantsForCommand> participants, IEnumerable <string> mcPkgScope, IEnumerable <string> commPkgScope) { McPkgScope = mcPkgScope != null?mcPkgScope.ToList() : new List <string>(); CommPkgScope = commPkgScope != null?commPkgScope.ToList() : new List <string>(); Participants = participants; Description = description; Location = location; StartTime = startTime; EndTime = endTime; ProjectName = projectName; Type = type; Title = title; }
public Discipline(DisciplineType name, int numberLectures, int numberExercises = 0) { this.Name = name; this.NumberOfLectures = numberLectures; this.NumberOfExcercises = numberExercises; }
private Lesson ToLesson(Schedule schedule) { Discipline discipline = _context.Discipline.Find(schedule.DisciplineID); DisciplineType disciplineType = _context.DisciplineType.Find(schedule.DisciplineTypeID); Cabinet cabinet = _context.Cabinet.Find(schedule.CabinetID); Teacher teacher = _context.Teacher.Find(schedule.TeacherId); StudyGroup group = _context.StudyGroup.Find(schedule.StudyGroupID); return(new Lesson(discipline, disciplineType, cabinet, teacher, group)); }
/// <summary> /// Создает экземляр класса <name>Discipline</name> /// </summary> /// <param name="code">Уникальный код дисциплины</param> /// <param name="russianName">Русское наименование дисциплины</param> /// <param name="englishName">Английское наименование дисциплины</param> /// <param name="type">Тип дисциплины</param> public Discipline(string code, string russianName, string englishName, DisciplineType type) { Code = code; RussianName = russianName; EnglishName = englishName; Type = type; ElectivesBlocks = new List <ElectivesBlock>(); Implementations = new List <DisciplineImplementation>(); }
public InvitationDto( int id, string projectName, string title, string description, string location, DisciplineType type, IpoStatus status, DateTime createdAtUtc, int createdById, DateTime startTimeUtc, DateTime endTimeUtc, DateTime?completedAtUtc, DateTime?acceptedAtUtc, string contractorRep, string constructionCompanyRep, IEnumerable <string> commissioningReps, IEnumerable <string> operationReps, IEnumerable <string> technicalIntegrityReps, IEnumerable <string> supplierReps, IEnumerable <string> externalGuests, IEnumerable <string> additionalContractorReps, IEnumerable <string> additionalConstructionCompanyReps, IEnumerable <string> mcPkgNos, IEnumerable <string> commPkgNos, string rowVersion) { Id = id; ProjectName = projectName; Title = title; Description = description; Location = location; Type = type; Status = status; CreatedAtUtc = createdAtUtc; CreatedById = createdById; StartTimeUtc = startTimeUtc; EndTimeUtc = endTimeUtc; CompletedAtUtc = completedAtUtc; AcceptedAtUtc = acceptedAtUtc; ContractorRep = contractorRep; ConstructionCompanyRep = constructionCompanyRep; CommissioningReps = commissioningReps; OperationReps = operationReps; TechnicalIntegrityReps = technicalIntegrityReps; SupplierReps = supplierReps; ExternalGuests = externalGuests; AdditionalContractorReps = additionalContractorReps; AdditionalConstructionCompanyReps = additionalConstructionCompanyReps; McPkgNos = mcPkgNos; CommPkgNos = commPkgNos; RowVersion = rowVersion; }
public static string Name(this DisciplineType discipline, DisciplineType type) { switch (type) { case DisciplineType.Base: return("Базовая"); case DisciplineType.Additional: return("Профильная"); default: return("Неизвестный тип"); } }
public bool IsValidScope( DisciplineType type, IList <string> mcPkgScope, IList <string> commPkgScope) { switch (type) { case DisciplineType.DP: return(mcPkgScope.Any() && !commPkgScope.Any()); case DisciplineType.MDP: return(!mcPkgScope.Any() && commPkgScope.Any()); default: return(false); } }
public static async Task <int> CreateInvitationAsync( UserType userType, string plant, string title, string description, string location, DisciplineType type, System.DateTime startTime, System.DateTime endTime, IList <CreateParticipantsDto> participants, IEnumerable <string> mcPkgScope, IEnumerable <string> commPkgScope, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { projectName = KnownTestData.ProjectName, title, description, location, type, startTime, endTime, participants, mcPkgScope, commPkgScope }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync(Route, content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(-1); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <int>(jsonString)); }
private bool TryParseDisciplineType(string text, out DisciplineType type) { switch (text.Trim()) { case "Базовая часть периода обучения": type = DisciplineType.Base; return(true); case "Вариативная часть периода обучения": type = DisciplineType.Elective; return(true); case "Факультативные занятия": type = DisciplineType.Facultative; return(true); } type = default; return(false); }
public InvitationForMainDto( int id, string title, string description, DisciplineType type, IpoStatus status, DateTime?completedAtUtc, DateTime?acceptedAtUtc, DateTime meetingTimeUtc, string rowVersion) { Id = id; Title = title; Description = description; Type = type; Status = status; CompletedAtUtc = completedAtUtc; AcceptedAtUtc = acceptedAtUtc; MeetingTimeUtc = meetingTimeUtc; RowVersion = rowVersion; }
public StudentDisciplines GetDisciplines(DisciplineType type) { var user = ServiceFactory.UserService.Find(SearchFilter <User> .FilterById(UserId)).SingleOrDefault(); var group = _groupService.Find(SearchFilter <Group> .FilterById(user.GroupId)).SingleOrDefault(); var filter = SearchFilter <Discipline> .Empty; filter.OptionList = type == DisciplineType.Socio ? FilterHelper.SocialDisciplines(user.Course.Value, true) : FilterHelper.SpecialDisciplines(user.Course.Value, group.DisciplineSubscriptions, true); var disciplines = Service.FindDisciplineResponse(filter); var userDisciplines = user.Disciplines != null && user.Disciplines.Any() ? Service.Find(SearchFilter <Discipline> .FilterByIds(user.Disciplines.Select(el => el.Id))) : new List <Discipline>(); var deadlines = _settingsSerivice.Find(SearchFilter <Setting> .Empty); var settings = group.DisciplineConfiguration; DisciplineConfiguration firstSemester = settings.SingleOrDefault(el => el.Semester % 2 == 1 && el.DisciplineType == type); DisciplineConfiguration secondSemester = settings.SingleOrDefault(el => el.Semester % 2 == 0 && el.DisciplineType == type); List <Discipline> userSocioDisciplines = userDisciplines.Where(ud => ud.DisciplineType == type).ToList(); var start = deadlines.SingleOrDefault(el => el.Name == Constants.StartDate)?.Value; var first = deadlines.SingleOrDefault(el => el.Name == Constants.FirstDeadline)?.Value; var second = deadlines.SingleOrDefault(el => el.Name == Constants.SecondDeadline)?.Value; bool checkTime = CheckTime(start, first, second); disciplines.ForEach(d => { d.IsLocked = user.Disciplines.Any(di => di.Id == d.Id && di.Locked); d.Registered = user.Disciplines.Any(di => di.Id == d.Id); d.CanRegister = CanRegister(d, firstSemester, secondSemester, userSocioDisciplines) && checkTime; }); return(new StudentDisciplines { Disciplines = disciplines.OrderByDescending(el => el.Count).ToList(), Type = DisciplineType.Socio, }); }
public Invitation( string plant, string projectName, string title, string description, DisciplineType type, DateTime startTimeUtc, DateTime endTimeUtc, string location, List <McPkg> mcPkgs, List <CommPkg> commPkgs) : base(plant) { mcPkgs ??= new List <McPkg>(); commPkgs ??= new List <CommPkg>(); if (string.IsNullOrEmpty(projectName)) { throw new ArgumentNullException(nameof(projectName)); } if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException(nameof(title)); } ProjectName = projectName; Title = title; Description = description; SetScope(type, mcPkgs, commPkgs); Status = IpoStatus.Planned; StartTimeUtc = startTimeUtc; EndTimeUtc = endTimeUtc; Location = location; ObjectGuid = Guid.NewGuid(); AddPreSaveDomainEvent(new IpoCreatedEvent(plant, ObjectGuid)); }
/// <summary> /// Creates or updates resources based on the natural key values of the supplied resource. The POST operation can be used to create or update resources. In database terms, this is often referred to as an "upsert" operation (insert + update). Clients should NOT include the resource "id" in the JSON body because it will result in an error (you must use a PUT operation to update a resource by "id"). The web service will identify whether the resource already exists based on the natural key values provided, and update or create the resource appropriately. /// </summary> /// <param name="body">The JSON representation of the "disciplineType" resource to be created or updated.</param> /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns> public IRestResponse PostDisciplineTypes(DisciplineType body) { var request = new RestRequest("/disciplineTypes", Method.POST); request.RequestFormat = DataFormat.Json; // verify required params are set if (body == null) { throw new ArgumentException("API method call is missing required parameters"); } request.AddBody(body); var response = client.Execute(request); var location = response.Headers.FirstOrDefault(x => x.Name == "Location"); if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString())) { body.id = location.Value.ToString().Split('/').Last(); } return(response); }
private void SetScope(DisciplineType type, IList <McPkg> mcPkgs, IList <CommPkg> commPkgs) { Type = type; switch (type) { case DisciplineType.DP when !mcPkgs.Any() || commPkgs.Any(): throw new ArgumentException("DP must have mc pkg scope and mc pkg scope only"); case DisciplineType.MDP when mcPkgs.Any() || !commPkgs.Any(): throw new ArgumentException("MDP must have comm pkg scope and comm pkg scope only"); case DisciplineType.DP: SetDpScope(mcPkgs); ClearMdpScope(); break; case DisciplineType.MDP: SetMdpScope(commPkgs); ClearDpScope(); break; } }
public void EditIpo( string title, string description, DisciplineType type, DateTime startTime, DateTime endTime, string location, IList <McPkg> mcPkgScope, IList <CommPkg> commPkgScope) { mcPkgScope ??= new List <McPkg>(); commPkgScope ??= new List <CommPkg>(); if (Status != IpoStatus.Planned) { throw new Exception($"Edit on {nameof(Invitation)} {Id} can not be performed. Status = {Status}"); } if (startTime > endTime) { throw new Exception($"Edit on {nameof(Invitation)} {Id} can not be performed. Start time is before end time"); } if (string.IsNullOrEmpty(title)) { throw new Exception($"Edit on {nameof(Invitation)} {Id} can not be performed. Title cannot be empty"); } Title = title; Description = description; SetScope(type, mcPkgScope, commPkgScope); StartTimeUtc = startTime; EndTimeUtc = endTime; Location = location; AddPreSaveDomainEvent(new IpoEditedEvent(Plant, ObjectGuid)); }
private List <Discipline> ParseDisciplines() { DisciplineType type = 0; var electivesBlockNumber = 1; var semester = 1; ElectivesBlock electivesBlock = null; var prevIntensity = 0; var prevMonitoringType = ""; List <Competence> prevCompetences = null; Specialization specialization = null; var table = body.Elements <Table>().Skip(3).First(); var rows = table.Elements <TableRow>().Skip(2); foreach (var row in rows) { if (row.Descendants <TableCell>().Count() == 1) { electivesBlockNumber = 1; specialization = null; var text = row.InnerText; if (TryParseDisciplineType(text, out DisciplineType newType)) { type = newType; } else if (text.Contains("Семестр")) { semester = ParseSemesterNumber(text); } else if (type == DisciplineType.Elective && !text.Contains("Не предусмотрено") && !text.Contains("год")) { specialization = GetSpecialization(text); } continue; } var nameCell = row.Elements <TableCell>().ElementAt(3); var(regNumber, rusName, engName, realization, trajectory) = ParseDisciplineNameCodeRealization(nameCell); if (regNumber == null) { continue; // для чистой математики } if (!disciplines.ContainsKey(regNumber)) { var discipline = new Discipline(regNumber, rusName, engName, type); disciplines.Add(regNumber, discipline); } var competencesCell = row.Elements <TableCell>().ElementAt(2); if (!string.IsNullOrEmpty(competencesCell?.InnerText)) { if (type == DisciplineType.Elective) { electivesBlock = new ElectivesBlock(semester, electivesBlockNumber, specialization); electivesBlocks.Add(electivesBlock); ++electivesBlockNumber; if (specialization != null) { specialization.ElectivesBlocks.Add(electivesBlock); } } prevCompetences = ParseDisciplineCompetences(competencesCell); } var intensityCell = row.Elements <TableCell>().ElementAt(1); if (!string.IsNullOrEmpty(intensityCell?.InnerText)) { prevIntensity = int.Parse(intensityCell.InnerText); } var monitoringTypeCell = row.Elements <TableCell>().ElementAt(4); if (!string.IsNullOrEmpty(monitoringTypeCell?.InnerText)) { prevMonitoringType = monitoringTypeCell.InnerText; } var workHours = ParseDisciplineWorkHours(row); var implementation = new DisciplineImplementation(disciplines[regNumber], semester, prevIntensity, realization, trajectory, prevMonitoringType, workHours, prevCompetences); disciplines[regNumber].Implementations.Add(implementation); if (type == DisciplineType.Elective) { electivesBlock.Disciplines.Add((disciplines[regNumber], implementation)); disciplines[regNumber].ElectivesBlocks.Add(electivesBlock); } } return(disciplines.Select(d => d.Value).ToList()); }
public Discipline(DisciplineType discipline, int numberOfLectures, int numberOfExercises) { this.discipline = discipline; this.numberOfLectures = numberOfLectures; this.numberOfExercises = numberOfExercises; }
public IEnumerable <PersonModel> GetAllStudentsByDisciplineName(DisciplineType discipline) { return(this._studentsMapper.Map(this._studentsRepo.GetAllStudentsByDisciplineId((int)discipline, (int)RoleType.Student))); }
public static ICollection <CompetitionDiscipline> FilteredCompetitionDisciplines(DisciplineType disciplineType) { using (HonglornDb db = new HonglornDb()) { return((from d in db.CompetitionDiscipline where d.Type == disciplineType select d).OrderBy(d => d.Name).ToArray()); } }
internal IEnumerable <StudentViewModel> GetAllStudentsByDisciplineName(DisciplineType discipline) { return(StudentsMapper.Map(this._studentsService.GetAllStudentsByDisciplineName(discipline))); }
public static ICollection <TraditionalDiscipline> FilteredTraditionalDisciplines(DisciplineType disciplineType, Sex sex) { using (HonglornDb db = new HonglornDb()) { return((from d in db.TraditionalDiscipline where d.Type == disciplineType && d.Sex == sex select d).OrderBy(d => d.Name).ToArray()); } }
private IEnumerable <StudentViewModel> GetAllStudentsByDisciplineName(DisciplineType discipline) { return(this._studentsController.GetAllStudentsByDisciplineName(discipline)); }
public void AddDisciplineType(DisciplineType disciplineType) { _context.DisciplineType.Add(disciplineType); _context.SaveChanges(); }
public static bool IsMerit(this DisciplineType row) { return(row <= DisciplineType.PositiveChanges); }