public ActionResult DeleteConfirmed(int id)
        {
            SchoolTask schoolTask = db.SchoolTasks.Find(id);

            db.SchoolTasks.Remove(schoolTask);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,title,description,whichClass")] SchoolTask schoolTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(schoolTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(schoolTask));
 }
        // GET: SchoolTasks/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SchoolTask schoolTask = db.SchoolTasks.Find(id);

            if (schoolTask == null)
            {
                return(HttpNotFound());
            }
            return(View(schoolTask));
        }
        public ActionResult Create([Bind(Include = "Id,title,description,whichClas")] SchoolTask schoolTask)
        {
            if (ModelState.IsValid)
            {
                string          currentTeacherId = User.Identity.GetUserId();
                ApplicationUser currentTeahcer   = db.Users.FirstOrDefault(x => x.Id == currentTeacherId);
                schoolTask.whichClas = currentTeahcer.Clas;
                db.SchoolTasks.Add(schoolTask);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(schoolTask));
        }
        public ActionResult NoteTask(int?id, string title)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SchoolTask schoolTask = db.SchoolTasks.Find(id);

            if (schoolTask == null)
            {
                return(HttpNotFound());
            }
            string          currentTeacherId = User.Identity.GetUserId();
            ApplicationUser currentTeahcer   = db.Users.FirstOrDefault(x => x.Id == currentTeacherId);

            ViewData["tytul"] = title;
            return(View(db.Users.ToList().Where(x => x.Clas == currentTeahcer.Clas)));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Put([FromBody] SchoolTask user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var result = await _service.Put(user);

                if (result != null)
                {
                    return(Ok(result));
                }

                return(BadRequest());
            }
            catch (ArgumentException ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Post([FromBody] SchoolTask user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var result = await _service.Post(user);

                if (result != null)
                {
                    return(Created(new Uri(Url.Link("GetById", new { id = result.Id })), result));
                }

                return(BadRequest());
            }
            catch (ArgumentException ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Ejemplo n.º 8
0
 public async Task <SchoolTask> Put(SchoolTask obj)
 {
     return(await _repository.UpdateAsync(obj));
 }
Ejemplo n.º 9
0
 public async Task <SchoolTask> Post(SchoolTask obj)
 {
     return(await _repository.InsertAsync(obj));
 }
Ejemplo n.º 10
0
 static void Main(string[] args)
 {
     SchoolTask.LoadAssembly(typeof(Program).Assembly, args);
 }