public async Task <ActionResult> Create([Bind(Include = "CCid,Cid,Oid,Name,Description,ProgramLength,ApplicationFee,TuitionFee,LivingCost,Code,Status")] CollegeCourse collegeCourse, string[] take, Intake section)
        {
            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    collegeCourse.Code   = uniquecode();
                    collegeCourse.Status = true;
                    db.CollegeCourses.Add(collegeCourse);

                    await db.SaveChangesAsync();

                    //  return RedirectToAction("Index");

                    for (int i = 0; i <= take.Length - 1; i++)
                    {
                        section.CCid       = collegeCourse.Code;
                        section.IntakeName = take[i].ToString();
                        section.Status     = true;
                        db.Intakes.Add(section);
                        db.SaveChanges();
                    }
                    ViewBag.Cid = new SelectList(db.Countries, "Cid", "CountryName", collegeCourse.Cid);
                    ViewBag.Oid = new SelectList(db.Colleges, "Oid", "Name", collegeCourse.Oid);
                    transaction.Commit();
                    return(RedirectToAction("Index", "CollegeCourses"));
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
Example #2
0
        private static void CreateObjects()
        {
            _person             = new Person();
            _person.Id          = 36346346346346;
            _person.DateOfBirth = Convert.ToDateTime("12-12-2012");

            _person.Firstname            = "weofimwef";
            _person.Middlename           = "jtytj";
            _person.Lastname             = "uliuli";
            _person.MotherFirstname      = "xvcbxbcv";
            _person.MotherMiddlename     = "ytjj";
            _person.MotherLastname       = "liuil";
            _person.FatherFirstname      = "wsdfsdf";
            _person.FatherMiddlename     = "nvnbvbn";
            _person.FatherLastname       = "uylliiyl";
            _person.DriversLicenseNumber = "34regdfdg";
            _person.PassportId           = "453dfdfgwr4";
            _person.SSN = "876969897";
            _person.BirthWeightPounds   = 2398.3m;
            _person.CurrentWeightPounds = 325.43m;
            _person.BirthHeightInches   = 45;
            _person.CurrentHeightInches = 11.111m;
            _person.AddressLine1        = "2938324 woeifmwoief";
            _person.AddressLine2        = "29rth rjrj";
            _person.City                         = "Foimwef";
            _person.State                        = "we";
            _person.Zip                          = "23423";
            _person.PhoneNumber                  = "23423411";
            _person.EmergencyContactName         = "ingle ingles";
            _person.EmergencyContactPhoneNumber  = "2346546324";
            _person.EmergencyContactAddressLine1 = "2938324 woeifmwoief";
            _person.EmergencyContactAddressLine2 = "29rth rjrj";
            _person.EmergencyContactCity         = "hrttheerg";
            _person.EmergencyContactState        = "AF";
            _person.EmergencyContactZip          = "80439";
            _person.EmergencyContactPhoneNumber  = "2938393398";

            _collegeCourse = new CollegeCourse
            {
                Id          = 12,
                Name        = "CMPS 101",
                Description = "L2p"
            };

            _personCollegeCourse    = new PersonCollegeCourse();
            _personCollegeCourse.Id = 239282;
            _personCollegeCourse.CollegeCourseId = 12;
            _personCollegeCourse.PersonId        = 36346346346346;

            _user = new User
            {
                Id        = 9460923,
                Email     = "*****@*****.**",
                Password  = "******",
                PersonId  = 36346346346346,
                IsDeleted = false
            };
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CollegeCourse collegeCourse = await db.CollegeCourses.FindAsync(id);

            db.CollegeCourses.Remove(collegeCourse);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public void TestCreateCourseWithNoPrerequisite()
        {
            //arrange
            var courseName = "Advanced Pyrotechnics";

            //act
            var collegeCourse = new CollegeCourse(courseName);

            //assert
            Assert.AreEqual(courseName, collegeCourse.Name);
        }
        public void TestCreateCourseWithTooManyPrerequisites()
        {
            //arrange
            var            courseName = "Advanced Pyrotechnics: Intro to Fire: How to Start a Blaze";
            ICollegeCourse collegeCourse;

            //act
            //assert
            Assert.Throws <InvalidCourseNameException>(
                () => { collegeCourse = new CollegeCourse(courseName); }
                );
        }
        public void TestCreateCourseWithEmptyName()
        {
            //arrange
            var            courseName = "   ";
            ICollegeCourse collegeCourse;

            //act
            //assert
            Assert.Throws <InvalidCourseNameException>(
                () => { collegeCourse = new CollegeCourse(courseName); }
                );
        }
Example #7
0
 private static UserCollegeCourseDto Map(Person person, CollegeCourse collegeCourse, User user)
 {
     return(new UserCollegeCourseDto
     {
         CollegeCourseId = collegeCourse.Id,
         CollegeCourseName = collegeCourse.Name,
         PersonFullname = $"{person.Firstname} {person.Middlename} {person.Lastname}",
         PersonId = person.Id,
         UserEmail = user.Email,
         UserId = user.Id
     });
 }
        public void TestCreateCouseWithPrerequisiteEmptyName()
        {
            //arrange
            var inputCourseName = "Advanced Pyrotechnics:    ";
            var courseName      = "Advanced Pyrotechnics";

            //act
            var collegeCourse = new CollegeCourse(inputCourseName);

            //assert
            Assert.AreEqual(courseName, collegeCourse.Name);
            Assert.AreEqual(null, collegeCourse.PrerequisteCourseName);
        }
        // GET: Auth/CollegeCourses/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CollegeCourse collegeCourse = await db.CollegeCourses.FindAsync(id);

            if (collegeCourse == null)
            {
                return(HttpNotFound());
            }
            return(View(collegeCourse));
        }
        public void TestCreateCouseWithPrerequisite()
        {
            //arrange
            var inputCourseName        = "Advanced Pyrotechnics: Introduction to Fire";
            var courseName             = "Advanced Pyrotechnics";
            var prerequisiteCourseName = "Introduction to Fire";

            //act
            var collegeCourse = new CollegeCourse(inputCourseName);

            //assert
            Assert.AreEqual(courseName, collegeCourse.Name);
            Assert.AreEqual(prerequisiteCourseName, collegeCourse.PrerequisteCourseName);
        }
        public int uniquecode()
        {
            CollegeCourse coursecode = db.CollegeCourses.FirstOrDefault();

            if (coursecode == null)
            {
                coursecode.Code = 1050;
            }
            else
            {
                var ab = db.CollegeCourses.Max(x => x.Code);
                coursecode.Code = Convert.ToInt32(ab) + 1;
            }
            return(coursecode.Code);
        }
        // GET: Auth/CollegeCourses/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CollegeCourse collegeCourse = await db.CollegeCourses.FindAsync(id);

            if (collegeCourse == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Cid = new SelectList(db.Countries, "Cid", "CountryName", collegeCourse.Cid);
            ViewBag.Oid = new SelectList(db.Colleges, "Oid", "Name", collegeCourse.Oid);
            return(View(collegeCourse));
        }
Example #13
0
 internal void DeregisterCourseWithCollege(AppDbContext context, CollegeCourse collegeCourse)
 {
     context.CollegeCourses.Remove(collegeCourse);
     context.SaveChanges();
 }
Example #14
0
        internal void RegisterCourseIdToCollegeId(AppDbContext context, CollegeCourse collegeCourse)
        {
            context.CollegeCourses.Add(collegeCourse);

            context.SaveChanges();
        }