Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "TopicID,TopicName,TopicDescription,CourseID,TrainerID")] Topic topic)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Topics.Add(topic);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                //db.Topics.Add(topic);
                //db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID  = new SelectList(db.Courses, "CourseID", "CourseName", topic.CourseID);
            ViewBag.TrainerID = new SelectList(db.Trainers, "TrainerID", "TrainerName", topic.TrainerID);
            return(View(topic));
        }
Ejemplo n.º 2
0
        public ActionResult InsertRegisterShopping(RegisterShopping rs)
        {
            rs.Name               = Request.Form["txtname"].ToString();
            rs.Gender             = Request.Form["gender"].ToString();
            rs.Membership         = Request.Form["ddlmember"].ToString();
            rs.ShoppingPreference = Request.Form["shop"].ToString();
            var res = Request.Form["cbcod"].ToString();

            if (res == "false")
            {
                rs.COD = "No";
            }
            else
            {
                rs.COD = "Yes";
            }
            rs.Password = Request.Form["txtpass"].ToString();
            db.RegisterShoppings.Add(rs);
            var result = db.SaveChanges();

            if (result > 0)
            {
                ModelState.AddModelError("", "Data Inserted");
            }
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "TopicID,TopicName,TopicDescription")] Topic topic)
        {
            if (ModelState.IsValid)
            {
                db.Topics.Add(topic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(topic));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "CourseID,CourseName,CourseDescription,Credit")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "TrainerID,TrainerName,Type,WorkingPlace,Phone,Address")] Trainer trainer)
        {
            if (ModelState.IsValid)
            {
                db.Trainers.Add(trainer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trainer));
        }
        public ActionResult Create([Bind(Include = "CateID,CourseID,CourseName,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "TraineeID,TraineeName,DoB,Education,Program_Language,TOEIC,ExperienceYear,Address")] Trainee trainee)
        {
            if (ModelState.IsValid)
            {
                db.Trainees.Add(trainee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trainee));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "TopicID,TopicName,TopicDescription,TrainerID")] Topic topic)
        {
            if (ModelState.IsValid)
            {
                db.Topics.Add(topic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TrainerID = new SelectList(db.Trainers, "TrainerID", "TrainerName", topic.TrainerID);
            return(View(topic));
        }
Ejemplo n.º 9
0
        public TblTrainingList Add(TblTrainingList item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // TO DO : Code to save record into database
            TrainingDB.TblTrainingLists.Add(item);
            TrainingDB.SaveChanges();
            return(item);
        }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "TraineeID,TraineeName,TraineeEmail,DOB,Education,ProgrammingLanguage,ToeicScore,Address")] Trainee trainee)
        {
            if (ModelState.IsValid)
            {
                db.Trainees.Add(trainee);
                db.SaveChanges();
                AuthenController.CreateAccount(trainee.TraineeEmail, "123456", "Trainee");
                return(RedirectToAction("Index"));
            }

            return(View(trainee));
        }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "CourseID,CourseName,CategoryID")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", course.CategoryID);
            return(View(course));
        }
Ejemplo n.º 12
0
        public ActionResult Create([Bind(Include = "TrainerID,TrainerName,WorkingPlace,Telephone,Email")] Trainer trainer)
        {
            if (ModelState.IsValid)
            {
                db.Trainers.Add(trainer);
                db.SaveChanges();

                AuthenController.CreateAccount(trainer.TrainerName, "123456", "Trainer");
                return(RedirectToAction("Index"));
            }

            return(View(trainer));
        }
        public ActionResult Create([Bind(Include = "EnrollmentID,CourseID,TraineeID")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                db.Enrollments.Add(enrollment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID  = new SelectList(db.Courses, "CourseID", "CourseName", enrollment.CourseID);
            ViewBag.TraineeID = new SelectList(db.Trainees, "TraineeID", "TraineeName", enrollment.TraineeID);
            return(View(enrollment));
        }
        public bool Post(UserInfo ui)
        {
            db.UserInfoes.Add(ui);
            var res = db.SaveChanges();

            if (res > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 15
0
        public ActionResult Create([Bind(Include = "TrainingStaffID,TrainingStaffUserID,TrainingStaffName,TrainingStaffDes")] TrainingStaff trainingStaff)
        {
            if (ModelState.IsValid)
            {
                db.TrainingStaffs.Add(trainingStaff);
                db.SaveChanges();

                AuthenController.CreateAccount(trainingStaff.TrainingStaffUserID, "123456", "TrainingStaff");

                return(RedirectToAction("Index"));
            }

            return(View(trainingStaff));
        }
        public ActionResult Create([Bind(Include = "TraineeID,TraineeUserID,TraineeName,TraineeAccount,DOB,Education,MPL,TOEIC_score,ExDetail,Department,Location")] Trainee trainee)
        {
            if (ModelState.IsValid)
            {
                db.Trainees.Add(trainee);
                db.SaveChanges();

                AuthenController.CreateAccount(trainee.TraineeUserID, "123456", "Trainee");

                return(RedirectToAction("Index"));
            }

            return(View(trainee));
        }
Ejemplo n.º 17
0
        public ActionResult Create([Bind(Include = "TrainingManagingID,TrainingStaffID,TraineeID,CourseCateID,CourseID,TopicID,TrainerID")] TrainningManaging trainningManaging)
        {
            if (ModelState.IsValid)
            {
                db.TrainningManagings.Add(trainningManaging);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID        = new SelectList(db.Courses, "CourseID", "CourseName", trainningManaging.CourseID);
            ViewBag.CourseCateID    = new SelectList(db.CourseCates, "CourseCateID", "CourseCateName", trainningManaging.CourseCateID);
            ViewBag.TopicID         = new SelectList(db.Topics, "TopicID", "TopicName", trainningManaging.TopicID);
            ViewBag.TraineeID       = new SelectList(db.Trainees, "TraineeID", "TraineeUserID", trainningManaging.TraineeID);
            ViewBag.TrainerID       = new SelectList(db.Trainers, "TrainerID", "TrainerUserID", trainningManaging.TrainerID);
            ViewBag.TrainingStaffID = new SelectList(db.TrainingStaffs, "TrainingStaffID", "TrainingStaffUserID", trainningManaging.TrainingStaffID);
            return(View(trainningManaging));
        }
Ejemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "TrainerID, TrainerName, WorkingPlace, Telephone, Email")] Trainer trainer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trainer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Profile"));
     }
     return(View(trainer));
 }
 public ActionResult Edit([Bind(Include = "TraineeID,TraineeName,TraineeAge,TraineeDoB,TraineeProgrammingLanguage,TraineePhone,TraineeAddress")] Trainee trainee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trainee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Profile"));
     }
     return(View(trainee));
 }
Ejemplo n.º 20
0
 public void Post([FromBody] Training training)
 {
     using (TrainingDBEntities entities = new TrainingDBEntities())
     {
         var maxItem = entities.Trainings.OrderByDescending(i => i.TrainingID).FirstOrDefault();
         var newID = maxItem == null ? 1 : maxItem.TrainingID + 1;
         training.TrainingID = newID;
         entities.Trainings.Add(training);
         entities.SaveChanges();
     }
 }
        public HttpResponseMessage Post([FromBody] TrainingModel TM)
        {
            try
            {
                TrainingInfo otInfo = new TrainingInfo();

                otInfo.TrainingName = TM.sTrainingName;
                otInfo.StartDate    = TM.stDate;
                otInfo.EndDate      = TM.endDate;

                TrainingDBEntities oDBContext = new TrainingDBEntities();
                oDBContext.TrainingInfoes.Add(otInfo);
                oDBContext.SaveChanges();
                TimeSpan t = TM.endDate - TM.stDate;
                TM.NumberofDays = t.TotalDays.ToString();

                return(Request.CreateResponse(HttpStatusCode.Created, TM));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
            }
        }