Пример #1
0
        public IHttpActionResult Putstudent(int id, student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != student.stu_id)
            {
                return(BadRequest());
            }

            db.Entry(student).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!studentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public ActionResult studentFileUpload(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    string path = Path.Combine(Server.MapPath("~/files"),
                                               Path.GetFileName(file.FileName));

                    int id = int.Parse(Session["studentId"].ToString());

                    studentEntities ctx = new studentEntities();
                    student_files   sf  = new student_files();
                    sf.create_date = DateTime.Now;
                    sf.filepath    = path;
                    sf.studentId   = id;
                    sf.fileNameOld = file.FileName;

                    ctx.student_files.Add(sf);
                    ctx.SaveChanges();
                    string extension = Path.GetExtension(file.FileName);
                    sf.fileName         = sf.id.ToString() + extension;
                    path                = path.Replace(file.FileName, sf.id.ToString() + extension);
                    ctx.Entry(sf).State = EntityState.Modified;
                    sf.filepath         = path;
                    ctx.SaveChanges();

                    file.SaveAs(path);
                    ViewBag.Message = "Dosya yüklendi.";

                    using (var context = new studentEntities())
                    {
                        ViewBag.PaymentsList = context.Student_Payments
                                               .Where(b => b.StudentId == id)
                                               .ToList();
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }
            return(View("General"));
        }
Пример #3
0
        public async Task <ActionResult> save_payment(Student_Payments model, string returnUrl)
        {
            int studentId = int.Parse(Session["studentId"].ToString());

            model.StudentId = studentId;
            //check for reportName parameter value now
            //to do : Return something
            studentEntities ee = new studentEntities();

            if (model.Id > 0)
            {
                ee.Entry(model).State = EntityState.Modified;
            }
            else
            {
                ee.Student_Payments.Add(model);
            }
            ee.SaveChanges();


            using (var context = new studentEntities())
            {
                ViewBag.PaymentsList = context.Student_Payments
                                       .Where(b => b.StudentId == studentId)
                                       .ToList();
            }

            return(View("General", ViewBag.PaymentsList));
        }
Пример #4
0
        public async Task <ActionResult> save(Student model, string returnUrl)
        {
            //check for reportName parameter value now
            //to do : Return something
            studentEntities ee = new studentEntities();

            if (model.Id > 0)
            {
                ee.Entry(model).State = EntityState.Modified;
            }
            else
            {
                ee.Students.Add(model);
                Session["studentId"] = model.Id;
            }
            ee.SaveChanges();
            General(model.Id);
            return(View("General"));
        }
Пример #5
0
        public ActionResult Edit(int?id, string firstname, string lastname, string email, int group_id)
        {
            if (firstname != "" && lastname != "" && email != "")
            {
                User usr = db.Users.FirstOrDefault(us => us.id == id);
                usr.Firstname = firstname;
                usr.Lastname  = lastname;
                usr.Email     = email;
                usr.Group_id  = group_id;
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Error = "Zehmet olmasa butun xanalari doldurun";
            }

            return(View());
        }
Пример #6
0
        public ActionResult General(int studentId)
        {
            Session["studentId"] = studentId;

            /*            Entities1 ee = new Entities1();
             *          Student ss = new Student
             *          {
             *              Id = 1,
             *              Active = true,
             *              StudentName = "test",
             *              StudentSurName = "testSurname",
             *              Adres="",
             *              StudentPapier=true,
             *              StudentPrice=0,
             *              StudentRestPrice=0,
             *              StudentExtraInfo="",
             *              StudentBirthDate=""
             *          };
             *          ee.Students.Add(ss);
             *          ee.SaveChanges();
             *          var std = ee.Students.Find();
             */

            /*
             * var std = new Models.Student { Id = 1, Email = "*****@*****.**", studentName = "STEFFY 1", studentSurName = "XYZ1" };
             * var pymts = new List<Models.Student_Payments>();
             * pymts.Add(new Models.Student_Payments { Id=1,Payment=100, date="1.1.2001"});
             * pymts.Add(new Models.Student_Payments { Id = 2, Payment = 102, date = "1.1.2001" });
             * pymts.Add(new Models.Student_Payments { Id = 3, Payment = 103, date = "1.1.2001" });
             * std.payments=pymts.ToArray();
             */
            studentEntities ee = new studentEntities();

            /*
             * ee.Students.Add( new Student {
             *  Id=1,
             *  StudentName ="test",
             *  StudentSurName ="test",
             *  StudentPrice=100,
             *  PhoneNumber="12345678"
             * });
             * ee.Students.Add(new Student
             * {
             *  Id = 2,
             *  StudentName = "test",
             *  StudentSurName = "test2",
             *  StudentPrice = 200,
             *  PhoneNumber = "22345678"
             * });
             * ee.Students.Add(new Student
             * {
             *  Id = 3,
             *  StudentName = "test2",
             *  StudentSurName = "test2x",
             *  StudentPrice = 300,
             *  PhoneNumber = "xx345678"
             * });
             * ee.Students.Add(new Student
             * {
             *  Id = 4,
             *  StudentName = "test2",
             *  StudentSurName = "testy",
             *  StudentPrice = 500,
             *  PhoneNumber = "1R3T5Z78"
             * });
             * ee.Student_Payments.Add(new Student_Payments { Payment = 100, StudentId = 1 });
             * ee.Student_Payments.Add(new Student_Payments { Payment = 200, StudentId = 1 });
             * ee.Student_Payments.Add(new Student_Payments { Payment = 300, StudentId = 3 });
             * ee.Student_Payments.Add(new Student_Payments { Payment = 400, StudentId = 3 });
             * ee.Student_Payments.Add(new Student_Payments { Payment = 500, StudentId = 2 });
             * ee.Student_Payments.Add(new Student_Payments { Payment = 600, StudentId = 2 });
             */
            ee.SaveChanges();

            Student sx = new Student();


            using (var context = new studentEntities())
            {
                /*
                 * var ss = from b in context.Students
                 *          where b.Id == 1
                 *          select b;
                 */
                // Query for the Blog named ADO.NET Blog

                sx = context.Students
                     .Where(b => b.Id == 1)
                     .FirstOrDefault();

                ViewBag.PaymentsList = context.Student_Payments
                                       .Where(b => b.StudentId == studentId)
                                       .ToList();
            }

            /*            svm.Payments = new List<Student_Payments>();
             *          foreach (var item in ee.Student_Payments)
             *          {
             *              svm.Payments.Add( new Student_Payments { Id=item.Id, Payment=item.Payment, StudentId=item.StudentId} );
             *          }
             */


            ViewBag.studentId = studentId;
            return(View());
        }