Esempio n. 1
0
        public ActionResult SaveUpdate(UpdateFormModel newupdate)
        {
            // Update update = Mapper.Map<UpdateFormModel, Update>(newupdate);
            if (ModelState.IsValid)
            {
                Update update = Mapper.Map<UpdateFormModel, Update>(newupdate);
                update.Goal = goalService.GetGoal(newupdate.GoalId);
                var updateVal = updateService.GetHighestUpdateValue(newupdate.GoalId);
               
                if(updateVal!=null)
                {  
                    if (updateVal.status <= newupdate.status)
                    {
                        updateService.CreateUpdate(update);
                       
                    }
                    else
                    {
                        update.status = -1;
                        ModelState.AddModelError(update.Updatemsg, "cannot enter");
                    }
                }
                else
                {
                    updateService.CreateUpdate(update);
                }


                     var Updates = Mapper.Map<IEnumerable<Update>, IEnumerable<UpdateViewModel>>(updateService.GetUpdatesByGoal(newupdate.GoalId));
                     foreach (var item in Updates)
                     {
                         item.IsSupported = updateSupportService.IsUpdateSupported(item.UpdateId, User.Identity.GetUserId());
                     }
                     UpdateListViewModel updates = new UpdateListViewModel()
                     {
                         Updates = Updates,
                         Metric = goalService.GetGoal(newupdate.GoalId).Metric,
                         Target = goalService.GetGoal(newupdate.GoalId).Target,
                         //IsSupported = updateSupportService.IsUpdateSupported(newupdate.UpdateId,((SocialGoalUser)(User.Identity)).UserId)
                     };
                     return PartialView("_UpdateView", updates);

            }
            return null;
        }
Esempio n. 2
0
 public ActionResult EditUpdate(UpdateFormModel newupdate)
 {
     Update update = Mapper.Map<UpdateFormModel, Update>(newupdate);
     if (ModelState.IsValid)
     {
         update.Goal = goalService.GetGoal(newupdate.GoalId);
         updateService.EditUpdate(update);
         var Updates = Mapper.Map<IEnumerable<Update>, IEnumerable<UpdateViewModel>>(updateService.GetUpdatesByGoal(newupdate.GoalId));
         foreach (var item in Updates)
         {
             item.IsSupported = updateSupportService.IsUpdateSupported(item.UpdateId, User.Identity.GetUserId());
         }
         UpdateListViewModel updates = new UpdateListViewModel()
         {
             Updates = Updates,
             Metric = goalService.GetGoal(newupdate.GoalId).Metric,
             Target = goalService.GetGoal(newupdate.GoalId).Target
         };
         return PartialView("_UpdateView", updates);
     }
     return null;
 }
Esempio n. 3
0
        public PartialViewResult DisplayUpdates(int id)
        {
            var Updates = Mapper.Map<IEnumerable<Update>, IEnumerable<UpdateViewModel>>(updateService.GetUpdatesByGoal(id));
            foreach (var item in Updates)
            {
                item.IsSupported = updateSupportService.IsUpdateSupported(item.UpdateId, User.Identity.GetUserId());
            }
            UpdateListViewModel updates = new UpdateListViewModel()
            {

                Updates = Updates,
                Metric = goalService.GetGoal(id).Metric,
                Target = goalService.GetGoal(id).Target,
                // IsSupported =  updateSupportService.IsUpdateSupported(,((SocialGoalUser)(User.Identity)).UserId)
            };
            return PartialView("_UpdateView", updates);
        }