Exemple #1
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));
        }
Exemple #2
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));
        }
Exemple #3
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"));
        }
Exemple #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"));
        }