Пример #1
0
        public Models.Subject checkSubjectDropDownList()
        {
            Models.Subject s     = Models.Subject.DYK600_Safety;
            int            value = SubjectDropDownList.SelectedIndex;

            switch (SubjectDropDownList.SelectedIndex)
            {
            case 1:
                s = Models.Subject.DYK601_Facilities;
                break;

            case 2:
                s = Models.Subject.DYK601_Plumbing;
                break;

            case 3:
                s = Models.Subject.DYK601_Saving;
                break;

            case 4:
                s = Models.Subject.RED110_Saving;
                break;

            default:
                break;
            }
            return(s);
        }
Пример #2
0
 private IList <Models.Grade> Grades;        // lista ocen ucznia z przedmiotu
 public ConcreteStudentPage(Models.Student student, Models.Subject subject)
 {
     _context = ((MainWindow)Application.Current.MainWindow).context;
     Student  = student;
     Subject  = subject;
     InitializeComponent();
 }
 public ActionResult DeleteSubject(int id)
 {
     Models.Subject model = _db.Subject.Find(id);
     _db.Subject.Remove(model);
     _db.SaveChanges();
     return(RedirectToAction("Subjects"));
 }
Пример #4
0
        public Models.Subject CreateSubject(string name, Guid subjectGroupId, string HighlightColor, bool isActive)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            if (subjectGroupId == null || subjectGroupId == System.Guid.Empty)
            {
                throw new ArgumentNullException("subjectGroupId");
            }

            Models.Subject subject = new Models.Subject()
            {
                Id             = Guid.NewGuid(),
                SubjectGroupId = subjectGroupId,
                Name           = name,
                HighlightColor = HighlightColor,
                IsActive       = isActive,
                IsDeleted      = false
            };

            this.DataContext.Insert <Models.Subject>(subject);

            return(subject);
        }
Пример #5
0
 private List <Models.Student> Students;         // lista uczniow, ktorzy ucza sie tego przedmiotu
 public ConcreteSubjectPage(Models.Subject subject, List <Models.Group> groups)
 {
     _context = ((MainWindow)Application.Current.MainWindow).context;
     Subject  = subject;
     Groups   = groups;
     InitializeComponent();
 }
        public ActionResult Subjects()
        {
            var subject = new Models.Subject()
            {
                Name = "Algebra", Difficulty = "Easy"
            };

            var problem = new List <Problem>
            {
                new Problem {
                    Id = 0001
                },
                new Problem {
                    Id = 0002
                }
            };

            var viewModel = new SubjectsViewModel
            {
                Subject = subject,
                Problem = problem
            };

            return(View(viewModel));
        }
Пример #7
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Models.Subject subject = (Models.Subject)value;
            int            index   = (int)subject - 1;

            return(index);
        }
Пример #8
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int index = (int)value;

            Models.Subject subject = (Models.Subject)index + 1;
            return(subject);
        }
Пример #9
0
 public async Task AddSubject(Models.Subject sub)
 {
     if (sub.StudentEmail == null)
     {
         sub.StudentEmail = new List <string>();
     }
     await _dbContext.Subjects().InsertOneAsync(sub);
 }
 //Edit
 public ActionResult EditSubject(int id)
 {
     Models.Subject model = _db.Subject.Find(id);
     if (model == null)
     {
         return(HttpNotFound());
     }
     return(View(model));
 }
 public ActionResult EditSubject(Models.Subject model)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(model).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Subjects"));
     }
     return(View(model));
 }
 public ActionResult CreateSubject(Models.Subject model)
 {
     if (ModelState.IsValid)
     {
         _db.Subject.Add(model);
         _db.SaveChanges();
         return(RedirectToAction("Subjects"));
     }
     return(View(model));
 }
Пример #13
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            string Tag = (e.Source as Button).Tag.ToString();       // wyciągamy Tag z przycisku

            string[] data = Tag.Split(' ');

            // znajdowanie przedmiotu po jego Id
            Models.Subject subject = SubjectList.First(s => s.Id.ToString() == data[1]);
            var            x       = GroupsForSubjects;

            this.NavigationService.Navigate(new ConcreteSubjectPage(subject, GroupsForSubjects[int.Parse(data[0])]));
        }
 //Delete
 public ActionResult DeleteSubject(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Models.Subject model = _db.Subject.Find(id);
     if (model == null)
     {
         return(HttpNotFound());
     }
     return(View(model));
 }
Пример #15
0
        public async Task <IActionResult> Post([FromBody] Models.Subject value)
        {
            try
            {
                await Subject.AddSubject(value);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Пример #16
0
        //Delete Subject
        public static bool DeleteSubject(Models.Subject subject)
        {
            try
            {
                using (var db = new Context.ContextDB())
                {
                    var toRemove = db.Subjects.FirstOrDefault(t => t.Id == subject.Id);
                    var query    = db.Subjects.Remove(toRemove);
                    db.SaveChanges();
                    return(true);
                }
            }
            catch { }

            return(false);
        }
Пример #17
0
        public static bool ChangePassword(Models.Subject subject, string password)
        {
            try
            {
                using (var db = new Context.ContextDB())
                {
                    var user = db.Subjects.FirstOrDefault(u => (u.Id == subject.Id));
                    user.Password = password;
                    db.SaveChanges();
                    return(true);
                }
            }
            catch { }

            return(false);
        }
Пример #18
0
        public async Task <(int Count, bool updated)> UpdateSubject(Models.Subject sub)
        {
            //check if theatre exists
            var count = await _dbContext.Theatres().Find(x => x.Name == sub.Lecture.Theatre).CountAsync();

            if (count > 0)
            {
                var result = await _dbContext.Subjects()
                             .FindOneAndUpdateAsync(
                    Builders <Models.Subject> .Filter.Eq(e => e.Name, sub.Name),
                    Builders <Models.Subject> .Update.Set(e => e.Lecture, sub.Lecture)
                    );

                return(result != null ? (1, true) : (1, false));
            }

            return(0, false);
        }
Пример #19
0
        public Models.Subject UpdateSubject(Guid id, string name, Guid subjectGroupId, string HighlightColor, bool isActive)
        {
            Models.Subject subject = this.GetById(id);

            if (subject == null)
            {
                throw new InvalidOperationException($"Subject ({id}) does not exist.");
            }

            subject.Name           = name;
            subject.SubjectGroupId = subjectGroupId;
            subject.HighlightColor = HighlightColor;
            subject.IsActive       = isActive;

            this.DataContext.Update <Models.Subject, Guid>(subject, x => x.Name, x => x.HighlightColor, x => x.IsActive);

            return(subject);
        }
Пример #20
0
        //Update subject
        public static bool UpdateSubject(Models.Subject subject)
        {
            try
            {
                using (var db = new Context.ContextDB())
                {
                    var query = db.Subjects.FirstOrDefault(q => q.Id == subject.Id);
                    query.Login    = subject.Login;
                    query.Password = subject.Password;
                    query.BanId    = subject.BanId;
                    query.LevelId  = subject.LevelId;
                    query.RoleId   = subject.RoleId;
                    db.SaveChanges();
                    return(true);
                }
            }
            catch { }

            return(false);
        }
Пример #21
0
        public async Task <IActionResult> AddLecture([FromBody] Models.Subject value)
        {
            try
            {
                var result = await Subject.UpdateSubject(value);

                if (result.Count <= 0)
                {
                    return(BadRequest("Theatre doesn't exist"));
                }
                if (!result.updated)
                {
                    return(BadRequest("Subject doesn't exist"));
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Пример #22
0
        public Models.Title GetTitle(int id)
        {
            Api2 apiProvider = new Api2();

            BHLApiData.Title bhlTitle = apiProvider.GetTitleMetadata(id.ToString(), "f");

            Models.Title title = null;
            if (bhlTitle != null)
            {
                title                      = new Models.Title();
                title.TitleId              = bhlTitle.TitleID;
                title.FullTitle            = bhlTitle.FullTitle;
                title.PartNumber           = bhlTitle.PartNumber;
                title.PartName             = bhlTitle.PartName;
                title.CallNumber           = bhlTitle.CallNumber;
                title.Edition              = bhlTitle.Edition;
                title.PublisherPlace       = bhlTitle.PublisherPlace;
                title.PublisherName        = bhlTitle.PublisherName;
                title.PublicationDate      = bhlTitle.PublicationDate;
                title.PublicationFrequency = bhlTitle.PublicationFrequency;
                title.BibliographicLevel   = bhlTitle.BibliographicLevel;

                List <Models.Subject> subjects = null;
                foreach (BHLApiData.Subject keyword in bhlTitle.Subjects)
                {
                    subjects = (subjects ?? new List <Models.Subject>());
                    Models.Subject subject = new Models.Subject();
                    subject.SubjectText = keyword.SubjectText;
                    subjects.Add(subject);
                }
                title.Subjects = subjects;

                List <Models.Author> authors = null;
                foreach (BHLApiData.Creator bhlAuthor in bhlTitle.Authors)
                {
                    authors = (authors ?? new List <Models.Author>());
                    Models.Author author = new Models.Author();
                    author.CreatorID  = bhlAuthor.CreatorID;
                    author.Type       = bhlAuthor.Role;
                    author.Name       = bhlAuthor.Name;
                    author.Dates      = bhlAuthor.Dates;
                    author.Numeration = bhlAuthor.Numeration;
                    author.Unit       = bhlAuthor.Unit;
                    author.Title      = bhlAuthor.Title;
                    author.Location   = bhlAuthor.Location;
                    author.FullerForm = bhlAuthor.FullerForm;
                    authors.Add(author);
                }
                title.Authors = authors;

                List <Models.Identifier> identifiers = null;
                foreach (BHLApiData.TitleIdentifier bhlIdentifier in bhlTitle.Identifiers)
                {
                    identifiers = (identifiers ?? new List <Models.Identifier>());
                    Models.Identifier identifier = new Models.Identifier();
                    identifier.IdentifierName   = bhlIdentifier.IdentifierName;
                    identifier.IdentifierValue  = bhlIdentifier.IdentifierValue;
                    identifier.RelationshipType = "same as";
                    identifiers.Add(identifier);
                }
                title.Identifiers = identifiers;
            }

            return(title);
        }
Пример #23
0
        public CreateAffairViewModel()
        {
            conn = DependencyService.Get <Isqlite>().GetConnection();

            SelectType = new Command(async(typeValue) => {
                AffairSubType = (string)typeValue;
                await CurrentNavigation.PopAsync();
            });

            LoadType = new Command(async() => {
                if (AffairType == "Event")
                {
                    await CurrentNavigation.PushAsync(new EventType(referenceEventViewModel));
                }
                else
                {
                    await CurrentNavigation.PushAsync(new ReminderType(referenceReminderViewModel));
                }
            });

            SelectRepeat = new Command(async(repeatValue) => {
                Repeat = (string)repeatValue;
                await CurrentNavigation.PopAsync();
            });

            LoadRepeat = new Command(async() => {
                if (AffairType == "Event")
                {
                    await CurrentNavigation.PushAsync(new Repeat(referenceEventViewModel));
                }
                else
                {
                    await CurrentNavigation.PushAsync(new Repeat(referenceReminderViewModel));
                }
            });

            SelectAlert = new Command(async(alertValue) => {
                Alert = (string)alertValue;
                await CurrentNavigation.PopAsync();
            });

            LoadAlert = new Command(async() => {
                if (AffairType == "Event")
                {
                    await CurrentNavigation.PushAsync(new Alert(referenceEventViewModel));
                }
                else
                {
                    await CurrentNavigation.PushAsync(new Alert(referenceReminderViewModel));
                }
            });

            SaveNote = new Command(async() => {
                List <Page> currentPages = (List <Page>)CurrentNavigation.NavigationStack;

                if (string.IsNullOrEmpty(NoteDescription) && string.IsNullOrEmpty(NoteURL))
                {
                    ErrorAlert("At least one field is required", currentPages[currentPages.Count - 1]);
                }
                else
                {
                    int isSuccess;
                    // Add Custom Note
                    Note newNote = new Note
                    {
                        Description = NoteDescription,
                        URL         = NoteURL
                    };
                    isSuccess = 0;
                    try
                    {
                        isSuccess = conn.Insert(newNote);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    CurrentNoteID = newNote.Id;
                    await CurrentNavigation.PopAsync();
                }
            });

            LoadNote = new Command(async() =>
            {
                if (AffairType == "Event")
                {
                    await CurrentNavigation.PushAsync(new Notes(referenceEventViewModel));
                }
                else
                {
                    await CurrentNavigation.PushAsync(new Notes(referenceReminderViewModel));
                }
            });

            LoadNewProgramme = new Command(() => {
                PopupProgrammeVisible = true;
            });

            SaveNewProgramme = new Command(() => {
                bool validProgramme = true;

                if (string.IsNullOrEmpty(NewProgrammeName))
                {
                    ErrorAlert("New Programme must have Name", CurrentPage);
                    validProgramme = false;
                }
                else if (string.IsNullOrEmpty(NewProgrammeColour))
                {
                    ErrorAlert("New Programme must have Colour", CurrentPage);
                    validProgramme = false;
                }

                if (validProgramme)
                {
                    int isSuccess;
                    // Add Programme
                    string hexCode;
                    switch (NewProgrammeColour)
                    {
                    case "Green":
                        hexCode = "#99ff33";
                        break;

                    case "Blue":
                        hexCode = "#0099ff";
                        break;

                    case "Red":
                        hexCode = "#ff5050";
                        break;

                    case "Orange":
                        hexCode = "#ff9966";
                        break;

                    case "Yellow":
                        hexCode = "#ffff99";
                        break;

                    case "Purple":
                        hexCode = "#993399";
                        break;

                    default:
                        hexCode = "#ffffff";
                        break;
                    }
                    if (AffairType == "Event")
                    {
                        Models.Calendar newCalendar = new Models.Calendar
                        {
                            Name      = NewProgrammeName,
                            HexColour = hexCode
                        };
                        isSuccess = 0;
                        try
                        {
                            isSuccess = conn.Insert(newCalendar);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    else
                    {
                        Models.Subject newSubject = new Models.Subject
                        {
                            Name      = NewProgrammeName,
                            HexColour = hexCode
                        };
                        isSuccess = 0;
                        try
                        {
                            isSuccess = conn.Insert(newSubject);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }

                    NewProgrammeName   = "";
                    NewProgrammeColour = "";
                    CurrentProgrammeID = 0;

                    // Save results to query
                    ProgrammeListView     = new List <ProgrammeViewModel>();
                    PopupProgrammeVisible = false;
                }
            });

            SelectProgramme = new Command((programmeValue) => {
                CurrentProgrammeID = 0;
                CurrentProgrammeID = (int)programmeValue;
                ProgrammeListView  = new List <ProgrammeViewModel>();
            });
        }
 public StudentSubjectJoin(StudentToSubject studentToSubject, Models.Subject subject)
 {
     this.StudentId = studentToSubject.StudentId;
     this.Grade     = studentToSubject.Grade;
     this.Subject   = subject;
 }
        public override System.Threading.Tasks.Task <System.Web.Mvc.ActionResult> Delete(System.Guid Id, Models.Subject model)
        {
            var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Delete);

            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Id", Id);
            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
            DeleteOverride(callInfo, Id, model);
            return(System.Threading.Tasks.Task.FromResult(callInfo as System.Web.Mvc.ActionResult));
        }
 partial void DeleteOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid Id, Models.Subject model);
 partial void CreateOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Models.Subject model);