public async Task <IActionResult> PutDailyRoutine(int id, DailyRoutine dailyRoutine)
        {
            if (id != dailyRoutine.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public IActionResult Create(int id) //this is the vet visit id
        {
            DailyRoutine dr = new DailyRoutine();

            dr.DogId = id;
            return(View(dr));
        }
Exemple #3
0
 protected bool FindGuardCharacter()
 {
     if (GuardCharacter == null)
     {
         //use the guard node to get the character
         if (GuardNode.HasOccupant)
         {
             if (!GuardNode.Occupant.Is <Character> (out GuardCharacter) || GuardCharacter.IsDead)
             {
                 //Debug.Log ("Couldn't get character from guard node occupant, quitting in " + name);
                 return(false);
             }
             DailyRoutine dr = null;
             if (GuardNode.Occupant.Has <DailyRoutine> (out dr))
             {
                 //guard nodes don't get to have routines
                 dr.Finish();
             }
         }
         else
         {
             //Debug.Log ("Guard node didn't have occupant, quitting in " + name);
             WIGroup group = null;
             if (WIGroups.FindGroup(GuardNode.State.ParentGroupPath, out group))
             {
                 Characters.GetOrSpawnCharacter(GuardNode, GuardNode.State.OccupantName, group, out GuardCharacter);
             }
             return(GuardCharacter != null);
         }
     }
     return(true);
 }
        public int CreateDailyRoutine(DailyRoutine dailyRoutine)
        {
            _aspnetGymTrackerContext.DailyRoutine.Add(dailyRoutine);

            _aspnetGymTrackerContext.SaveChanges();

            return(dailyRoutine.RoutineId);
        }
        public void UpdateDailyProgress(DailyRoutine dailyRoutine)
        {
            _aspnetGymTrackerContext.DailyProgress.RemoveRange(_aspnetGymTrackerContext.DailyProgress.Where(c => c.RoutineId == dailyRoutine.RoutineId && c.Date >= DateTime.Today));

            _aspnetGymTrackerContext.SaveChanges();

            CreateDailyProgress(dailyRoutine);
        }
 public int AddDailyRoutine(DailyRoutine DR)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new GreencardContext()))
     {
         unitOfWork.AdherenceDailyRoutineRepository.Add(DR);
         unitOfWork.Complete();
         unitOfWork.Dispose();
         return(DR.Id);
     }
 }
        public IActionResult Update(int id)
        {
            DailyRoutine dr = repository.GetDailyRoutineById(id);

            if (dr != null)
            {
                return(View(dr));
            }
            return(RedirectToAction("Detail", "Dog"));
        }
 public int updateDailyRoutine(DailyRoutine DR)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new GreencardContext()))
     {
         unitOfWork.AdherenceDailyRoutineRepository.Update(DR);
         result = unitOfWork.Complete();
         unitOfWork.Dispose();
         return(result);
     }
 }
        public void UpdateDailyRoutine(DailyRoutine dailyRoutine)
        {
            var result = _aspnetGymTrackerContext.DailyRoutine.SingleOrDefault(b => b.RoutineId == dailyRoutine.RoutineId);

            if (result != null)
            {
                result.StartDate = dailyRoutine.StartDate;
                result.EndDate   = dailyRoutine.EndDate;
                result.Interval  = dailyRoutine.Interval;
                result.Sets      = dailyRoutine.Sets;
                _aspnetGymTrackerContext.SaveChanges();
            }
        }
        public int addDailyRoutine(int patientId, int patientMasterVisitId, int createdBy, string typicalDay, string medicineAdministration, string travelCase, string primaryCaregiver)
        {
            DailyRoutine DR = new DailyRoutine()
            {
                PatientId              = patientId,
                PatientMasterVisitId   = patientMasterVisitId,
                TypicalDay             = typicalDay,
                MedicineAdministration = medicineAdministration,
                TravelCase             = travelCase,
                PrimaryCaregiver       = primaryCaregiver
            };

            Result = _adherence.AddDailyRoutine(DR);
            return(Result);
        }
        public IActionResult AssignExercise(TraineeDetailsPageViewModel model)
        {
            model.ExStartDate = DateTime.ParseExact(model.StrExStartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            model.ExEndDate   = DateTime.ParseExact(model.StrExEndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            DailyRoutine dailyRoutine = new DailyRoutine
            {
                ExerciseId = model.ExId,
                TraineeId  = model.Id,
                StartDate  = model.ExStartDate,
                EndDate    = model.ExEndDate,
                Interval   = model.ExInterval,
                Sets       = model.ExSets
            };

            dailyRoutine.RoutineId = _dailyRoutineRepository.CreateDailyRoutine(dailyRoutine);
            _dailyProgressRepository.CreateDailyProgress(dailyRoutine);
            return(RedirectToAction("TraineeDetails", "Home", new { Id = model.Id }));
        }
Exemple #12
0
        public IActionResult DailyRoutineHandler(DailyRoutine FromForm)
        {
            System.Console.WriteLine($"you have reached the backend of daily routine {FromForm.Activity}");
            if (HttpContext.Session.GetInt32("UserId") == null)
            {
                return(RedirectToAction("index"));
            }
            int GetUserbyId = (int)HttpContext.Session.GetInt32("UserId");

            FromForm.UserId = GetUserbyId;


            _context.Add(FromForm);
            _context.SaveChanges();



            return(Json(new { Status = "Success" }));
        }
        public void CreateDailyProgress(DailyRoutine dailyRoutine)
        {
            DateTime date = dailyRoutine.StartDate;

            while (date < DateTime.Today)
            {
                date = date.AddDays(dailyRoutine.Interval);
            }
            while (date <= dailyRoutine.EndDate)
            {
                DailyProgress dailyProgress = new DailyProgress
                {
                    ExerciseId   = dailyRoutine.ExerciseId,
                    RoutineId    = dailyRoutine.RoutineId,
                    AssignedSets = dailyRoutine.Sets,
                    Date         = date,
                    TraineeId    = dailyRoutine.TraineeId
                };
                _aspnetGymTrackerContext.DailyProgress.Add(dailyProgress);
                date = date.AddDays(dailyRoutine.Interval);
            }

            _aspnetGymTrackerContext.SaveChanges();
        }
 public IActionResult Delete(DailyRoutine dr)
 {
     repository.DeleteDailyRoutine(dr.Id);
     return(RedirectToAction("Detail", "Dog", new { id = dr.DogId }));
 }
        public IActionResult Delete(int id)
        {
            DailyRoutine dailyRoutine = repository.GetDailyRoutineById(id);

            return(View(dailyRoutine));
        }
        public IActionResult Update(DailyRoutine dr)
        {
            DailyRoutine dr2 = repository.UpdateDailyRoutine(dr);

            return(RedirectToAction("Detail", "Dog", new { id = dr.DogId }));
        }
 public IActionResult Create(DailyRoutine dr)
 {
     dr.Id = 0; //Hack / fix
     repository.Create(dr);
     return(RedirectToAction("Detail", "Dog", new { id = dr.DogId }));
 }
        public async Task <ActionResult <DailyRoutine> > PostDailyRoutine(int userId, DailyRoutine dailyRoutine)
        {
            Console.WriteLine("Go for it:" + userId);
            dailyRoutine.UserId = userId;
            _context.DailyRoutine.Add(dailyRoutine);
            await _context.SaveChangesAsync();

            Console.WriteLine("Insert Ok");

            return(CreatedAtAction("GetDailyRoutine", new { id = dailyRoutine.Id }, dailyRoutine));
        }