Exemplo n.º 1
0
 public ActionResult CheckIn(WeightCheckInModel weightCheckInModel)
 {
     string userName = User.Identity.Name;
     AccountModel user = AccountRepository.GetAccount(userName);
     weightCheckInModel.UserId = user.UserId;
     WeightRepository.InsertWeightCheckIn(weightCheckInModel);
     return RedirectToAction("WeightCheckIns");
 }
Exemplo n.º 2
0
 public WeightCheckInModel GetCheckInWeight(int checkInId)
 {
     using (Entities entity = new Entities(BaseBISL.ConnectionString))
     {
         var weight = entity.WeightCheckIns.Include("WeightUser").Where(e => e.CheckInID == checkInId).FirstOrDefault();
         if (weight != null)
         {
             WeightCheckInModel model = new WeightCheckInModel();
             model.CheckInId = weight.CheckInID;
             model.UserId = weight.UserID;
             model.UserName = weight.WeightUser.UserName;
             model.Weight = weight.Weight;
             model.CheckInDate = weight.CheckInDate;
             return model;
         }
     }
     return null;
 }
Exemplo n.º 3
0
 public List<WeightCheckInModel> GetCheckInWeights(int userId)
 {
     List<WeightCheckInModel> weightList = new List<WeightCheckInModel>();
     using (Entities entity = new Entities(BaseBISL.ConnectionString))
     {
         var weights = entity.WeightCheckIns.Include("WeightUser").Where(e => e.UserID == userId);
         foreach (var weight in weights)
         {
             WeightCheckInModel model = new WeightCheckInModel();
             model.CheckInId = weight.CheckInID;
             model.UserId = weight.UserID;
             model.UserName = weight.WeightUser.UserName;
             model.Weight = weight.Weight;
             model.CheckInDate = weight.CheckInDate;
             weightList.Add(model);
         }
     }
     return weightList;
 }
Exemplo n.º 4
0
 public ActionResult Edit(WeightCheckInModel model)
 {
     WeightRepository.UpdateCheckIn(model);
     return RedirectToAction("WeightCheckIns");
 }
Exemplo n.º 5
0
 public bool InsertWeightCheckIn(WeightCheckInModel model)
 {
     using (Entities entity = new Entities(BaseBISL.ConnectionString))
     {
         WeightCheckIn checkIn = new WeightCheckIn();
         checkIn.UserID = model.UserId;
         checkIn.Weight = model.Weight;
         checkIn.CheckInDate = model.CheckInDate;
         entity.AddToWeightCheckIns(checkIn);
         int count = entity.SaveChanges();
         if (count > 0)
             return true;
     }
     return false;
 }
Exemplo n.º 6
0
        public bool UpdateCheckIn(WeightCheckInModel model)
        {
            using (Entities entity = new Entities(BaseBISL.ConnectionString))
            {
                WeightCheckIn checkIn = entity.WeightCheckIns.Where(e => e.CheckInID == model.CheckInId).FirstOrDefault();

                if (checkIn != null)
                {
                    //user.UserName = accountModel.UserName;
                    checkIn.CheckInDate = model.CheckInDate;
                    checkIn.Weight = model.Weight;
                    int count = entity.SaveChanges();
                    if (count > 0)
                        return true;
                }
            }
            return false;
        }