示例#1
0
 public ActionResult Edit([Bind(Include = "Id,Name,Lastname,Productivity,TeamId")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TeamId = new SelectList(db.Teams, "Id", "Description", employee.TeamId);
     return(View(employee));
 }
        public async Task <IActionResult> PutPost(int id, Post post)
        {
            if (id != post.PostId)
            {
                return(BadRequest());
            }

            Post postUpdate = _context.Posts.Find(id);

            postUpdate.Titulo    = post.Titulo;
            postUpdate.Contenido = post.Contenido;

            _context.Entry(postUpdate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        // GET: Tasks/MarkAsDone
        public ActionResult MarkAsDone(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var task = db.Tasks.Find(id);

            task.IsDone          = true;
            db.Entry(task).State = EntityState.Modified;
            db.SaveChanges();

            Employee employee = db.Employees.Find(task.EmployeeId);

            Productivity.CalculateProductivity(employee);
            Productivity.TeamProductivity(employee.Team);
            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }