示例#1
0
        public void AfterDeleteSubjectCodeIsAvailableToCreateNewSubject()
        {
            ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations();
            Subject       subject           = new Subject(1000, "Logic");

            subjectOperations.AddSubject(subject);
            subjectOperations.DeleteSubjectByCode(subject.GetCode());
            Subject anotherSubject = new Subject(1000, "Logic");

            subjectOperations.AddSubject(anotherSubject);
            Assert.IsNotNull(this.FindSubjectOnSystem(anotherSubject.GetCode()));
        }
示例#2
0
        public void AddSubjectToSystem()
        {
            ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations();
            Subject       newSubject        = new Subject(1, "Logic");

            subjectOperations.AddSubject(newSubject);

            Assert.IsNotNull(this.FindSubjectOnSystem(newSubject.GetCode()));
        }
示例#3
0
        public void DeleteSubject()
        {
            ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations();

            Subject subject = new Subject(1000, "Logic");

            subjectOperations.AddSubject(subject);
            subjectOperations.DeleteSubjectByCode(1000);
            Assert.IsNull(this.FindSubjectOnSystem(1000));
        }
示例#4
0
        public void TryToAddSubjectThatAlreadyExistsToSystem()
        {
            try
            {
                ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations();

                Subject firstTeacher  = new Subject(1, "Logic");
                Subject secondTeacher = new Subject(1, "Logic");
                subjectOperations.AddSubject(firstTeacher);
                subjectOperations.AddSubject(secondTeacher);

                Assert.Fail();
            }
            catch (CoreException ex)
            {
                Assert.IsTrue(ex.Message.Equals("Subject already exists."));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
示例#5
0
        public void ModifySubject()
        {
            ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations();

            int     subjectCode = 1;
            Subject subject     = new Subject(subjectCode, "Logic");

            subjectOperations.AddSubject(subject);

            subject.SetName("LogicModified");
            subjectOperations.ModifySubjectByCode(subjectCode, subject);

            Subject modifiedSubject = subjectOperations.GetSubjectByCode(subjectCode);

            Assert.AreEqual(modifiedSubject.GetName(), "LogicModified");
        }
示例#6
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            this.labelOk.Visible    = false;
            this.labelError.Visible = false;
            try
            {
                this.labelError.Visible = false;
                string  name;
                int     code;
                Subject subject = new Subject();
                if (int.TryParse(this.textBoxSubjectCode.Text, out code))
                {
                    if (!string.IsNullOrWhiteSpace(this.textBoxSubjectName.Text))
                    {
                        subject.Code = code;
                        name         = this.textBoxSubjectName.Text;
                        subject.Name = name;

                        ISubjectLogic subjectsOperations = Provider.GetInstance.GetSubjectOperations();
                        subjectsOperations.AddSubject(subject);

                        this.ClearAddSubjectForm();
                        this.ShowCorrectlyAddedSubjectMessage(code, name);
                    }
                    else
                    {
                        this.labelError.Visible = true;
                        this.labelError.Text    = "Subject's name must be a not empty string";
                    }
                }
                else
                {
                    this.labelError.Visible = true;
                    this.labelError.Text    = "Subject's code must be a number";
                }
            }
            catch (CoreException ex)
            {
                this.labelError.Text    = ex.Message;
                this.labelError.Visible = true;
            }
            catch (Exception ex)
            {
                this.labelError.Text    = ex.Message;
                this.labelError.Visible = true;
            }
        }
 public ActionResult Create(SubjectCreateVM subject, int id)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _subjectLogic.AddSubject(Mapper.Map <SubjectCreateVM, Subject>(subject));
             // return RedirectToAction("IndexForTeacher",id);
             return(RedirectToAction("Index", "Home"));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(String.Empty, ex);
     }
     return(View(subject));
 }