Exemplo n.º 1
0
 public ActionResult Edit(int id)
 {
     if (!isAuthenticated() || !loggedUser.isAdmin)
         return new HttpUnauthorizedResult();
     else
     {
         ActivityViewModel model = new ActivityViewModel();
         Activity activity = new Activity().get(id, loggedUser.Unit);
         model.Id = activity.Id;
         model.Name = activity.Name;
         model.Date = activity.Date;
         model.Place = activity.Place;
         model.Obs = activity.Obs;
         return View(model);
     }
 }
Exemplo n.º 2
0
        public ActionResult Edit(ActivityViewModel model, string hour, string minute)
        {
            if (!isAuthenticated() || !loggedUser.isAdmin)
                return new HttpUnauthorizedResult();
            else
            {
                if (ModelState.IsValid)
                {
                    Activity activity = new Activity();
                    Result result = activity.update(model.Id, model.Name,
                        new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, new Common().convertNumber(hour), new Common().convertNumber(minute), 0),
                        model.Place,
                        model.Obs,
                        loggedUser.Unit);
                    if (result.Success)
                        return RedirectToAction("Index");
                    else
                        ModelState.AddModelError("", "Ocorreu um erro ao atualizar atividade");
                }

                return View(model);
            }
        }
Exemplo n.º 3
0
 public ActionResult New()
 {
     if (!isAuthenticated() || !loggedUser.isAdmin)
         return new HttpUnauthorizedResult();
     else
     {
         ActivityViewModel model = new ActivityViewModel();
         model.Date = DateTime.Now;
         return View(model);
     }
 }