public ActionResult ActiveActivity(Nullable <int> id)
        {
            UserViewModel user = Session["User"] as UserViewModel;

            if (user.assistance != null)
            {
                IActivityDAL dalAct             = new ActivityImpl();
                ActivitieAssistanceViewModel aa = ActivitieAssistanceViewModel.Converter(dalAct.GetCurrentActivity(user.assistance.idAssistance));
                if (aa != null)
                {
                    return(RedirectToAction("Working", new { id = aa.idActivityAssistance }));
                }
                else
                {
                    if (id == null)
                    {
                        TempData["status"] = false;
                        TempData["msg"]    = "No hay ninguna actividad activa";
                        return(RedirectToAction("Index"));
                    }
                    ActivityViewModel activity;
                    using (var u = new UnitWork <Activity>()) {
                        activity = ActivityViewModel.Converter(u.genericDAL.Get(id.GetValueOrDefault(-1)));
                    }
                    if (activity != null)
                    {
                        aa = ActivitieAssistanceViewModel.Converter(dalAct.StartActivity(ActivitieAssistanceViewModel.Converter(new ActivitieAssistanceViewModel(user, activity.idActivity))));
                        TempData["status"] = aa != null;
                        TempData["msg"]    = "Actividad nueva generada";
                        if (aa == null)
                        {
                            TempData["msg"] = "No se podo generar la sesion de esta actividad";
                        }
                        else
                        {
                            aa.activity = activity;
                        }
                        return(RedirectToAction("Working", new { id = aa.idActivityAssistance }));
                    }
                    else
                    {
                        TempData["status"] = false;
                        TempData["msg"]    = "Error al obtener la actividad";
                    }
                }
            }
            else
            {
                TempData["status"] = false;
                TempData["msg"]    = "Debes tener una asistencia activa.";
            }
            return(RedirectToAction("Index"));
        }
Example #2
0
        public void MakeActivity()
        {
            IActivityDAL       dalAct = new ActivityImpl();
            Activity_Assitance aa     = dalAct.StartActivity(new Activity_Assitance()
            {
                idActivity   = 1,
                idAssistance = 19,
                end          = null,
                kcal         = -5,
                start        = DateTime.Now,
                status       = false,
                timeOcurred  = "00:00:00"
            });

            Assert.AreEqual(true, aa != null);
        }