Beispiel #1
0
        public ActionResult Create([Bind(Include = "Username,Firstname,Lastname,Likes,Retweets,Text")] TweetGenerator tweetGenerator)
        {
            if (ModelState.IsValid)
            {
                db.TweetGenerators.Add(tweetGenerator);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tweetGenerator));
        }
        public ActionResult Create(PaymentDetail paymentDetail)
        {
            if (ModelState.IsValid)
            {
                paymentDetail.PaymentDate = DateTime.UtcNow;
                db.PaymentDetails.Add(paymentDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GradeId   = new SelectList(db.Grades, "Id", "ClassName", paymentDetail.GradeId);
            ViewBag.StudentId = new SelectList(db.StudentInfoes, "Id", "Name", paymentDetail.StudentId);
            return(View(paymentDetail));
        }
Beispiel #3
0
        public HttpResponseMessage Delete(int id)
        {
            try
            {
                using (SMSDBEntities entities = new SMSDBEntities())
                {
                    var question = entities.questions.FirstOrDefault(q => q.qid == id);

                    if (question == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Question with id = " + id + " not found"));
                    }
                    else
                    {
                        entities.questions.Remove(question);
                        entities.SaveChanges();

                        var message = Request.CreateResponse(HttpStatusCode.OK);
                        message.Headers.Location = new Uri(Request.RequestUri + id.ToString());

                        return(message);
                    }
                }
            }
            catch (Exception exp)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exp));
            }
        }
        public HttpResponseMessage Put(int id, [FromBody] survey survey)
        {
            try
            {
                using (SMSDBEntities entities = new SMSDBEntities())
                {
                    var entity = entities.surveys.FirstOrDefault(s => s.sid == id);

                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Survey with id = " + id.ToString() + " not found to update"));
                    }
                    else
                    {
                        entity.title = survey.title;

                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception exp)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exp));
            }
        }
        public ActionResult Attend(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var        student = db.StudentInfoes.First(s => s.Id == id);
            Attendance attend  = new Attendance
            {
                StudentId      = student.Id,
                GradeId        = student.Grade.Id,
                IsPresent      = true,
                IsCounted      = true,
                AttendanceDate = DateTime.Now
            };

            db.Attendances.Add(attend);
            db.SaveChanges();
            return(RedirectToAction("CreateAttendance", "Attendances", new { id = student.Grade.Id }));
        }
Beispiel #6
0
        //==============================end===============================//



        public void Save()
        {
            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
0
        public HttpResponseMessage Post([FromBody] question question)
        {
            try
            {
                using (SMSDBEntities entities = new SMSDBEntities())
                {
                    entities.questions.Add(question);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, question);
                    message.Headers.Location = new Uri(Request.RequestUri + question.qid.ToString());

                    return(message);
                }
            }
            catch (Exception exp)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exp));
            }
        }
Beispiel #8
0
 //=====================END==========================//
 public void Save()
 {
     context.SaveChanges();
 }
Beispiel #9
0
 public void Save()
 {
     _smsdb.SaveChanges();
 }