Exemplo n.º 1
0
        private void SetItems(string task, ObjectifViewModel objVm)
        {
            ObjectifType type = objCtx.GetObjectifTypeByName(task);

            objVm.Items = objCtx.GetItems(type.Id).Select(a => a.Name).Distinct().ToList();
            objVm.Type  = task;
        }
Exemplo n.º 2
0
        private void initViewModel(ObjectifViewModel obj, string task)
        {
            SetItems(task, obj);
            var lastMonth     = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            var lastLastMonth = lastMonth.AddMonths(-1);

            SetCharts(task, "ThisMonth", lastMonth, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), obj);
            SetCharts(task, "LastMonth", lastLastMonth, lastMonth, obj);
        }
Exemplo n.º 3
0
        public ActionResult AddTask(ObjectifViewModel objVm)
        {
            string type = objVm.Type;

            if (ModelState.IsValid)
            {
                ObjectifType objectifType = objCtx.GetObjectifTypeByName(type);
                objectifType.Items = new List <Item>();

                if (!objVm.Items.Contains(objVm.Tache))
                {
                    objectifType.Items.Add(new Item {
                        Name = objVm.Tache
                    });
                }

                var objectif = new Objectif
                {
                    Date        = objVm.Date,
                    NbPoint     = objVm.NbPoint,
                    ObjTypeId   = objectifType.Id,
                    Commentaire = objVm.Commentaire,
                    UserId      = userCtx.GetUserIdWhithName(User.Identity.Name),
                    Tache       = objVm.Tache
                };

                objCtx.AddObjectif(objectif);
                objVm.Objectifs   = objCtx.GetObjectifsByType(type);
                objVm.Commentaire = string.Empty;
                objVm.Date        = DateTime.Now;
                objVm.NbPoint     = 0;
            }
            else
            {
                objVm.Date    = DateTime.Now;
                objVm.isValid = false;
            }
            initViewModel(objVm, type);
            return(View("Objectif", objVm));
        }
Exemplo n.º 4
0
 public ObjectifController([FromServices] IObjectifDataContext objCtx, [FromServices] IUserDataContext userCtx)
 {
     this.objCtx  = objCtx;
     this.userCtx = userCtx;
     objVm        = new ObjectifViewModel();
 }
Exemplo n.º 5
0
        private void SetCharts(string task, string name, DateTime startDate, DateTime endDate, ObjectifViewModel objVm)
        {
            var     objectifs = objCtx.GetObjectifsByType(task);
            ACharts chart     = new Gauge(task, name, new Dictionary <string, List <Objectif> > {
                { name, objectifs.Where(a => a.Date >= startDate && a.Date <= endDate).ToList() }
            });

            chart.ComputeChart();
            objVm.Charts.Add(chart);
        }