public ActionResult UserCallOverview(int skillId, int?answerId, int?coreTemperatureId)
        {
            UserCallOverviewViewModel model = new UserCallOverviewViewModel()
            {
                SkillId          = skillId,
                Answers          = GetAnswers(),
                CoreTemperatures = GetCoreTemperature()
            };

            using (AlexaSkillEntities db = new AlexaSkillEntities())
            {
                List <Meat> userCalls;

                if (answerId == null && coreTemperatureId == null)
                {
                    userCalls = db.Meats.OrderBy(x => x.Name).ToList();
                }
                else if (answerId.HasValue)
                {
                    userCalls = db.Meats.Where(x => x.AnswerId == answerId).OrderBy(x => x.Name).ToList();
                }
                else if (coreTemperatureId.HasValue)
                {
                    userCalls = db.Meats.Where(x => x.CoreTemperatureId == coreTemperatureId).OrderBy(x => x.Name).ToList();
                }
                else
                {
                    userCalls = db.Meats.OrderBy(x => x.Name).ToList();
                }

                foreach (Meat userCall in userCalls)
                {
                    UserCallViewModel newUserCall = new UserCallViewModel()
                    {
                        UserCallId   = userCall.Id,
                        UserCallName = userCall.Name
                    };

                    if (userCall.AnswerId != null)
                    {
                        newUserCall.AnswerId   = userCall.AnswerId;
                        newUserCall.AnswerText = userCall.Answer.Answert;
                    }

                    if (userCall.CoreTemperatureId != null)
                    {
                        newUserCall.CoreTemperatureId  = userCall.CoreTemperatureId;
                        newUserCall.CoreTemeratureName = userCall.CoreTemperature.Name;
                    }

                    model.UserCalls.Add(newUserCall);
                }
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult UpdateEquipmentMonitoring(EquipmentMonitoringViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Users = new BusinessLayer <User>(new CapaNavDocDal()).GetList().Select(u => u.ToUserCallViewModel().UserCall).ToList();
                return(PartialView("EquipmentMonitoringView", model));
            }

            BusinessLayer <Equipment> ebl       = new BusinessLayer <Equipment>(new CapaNavDocDal());
            BusinessLayer <User>      ubl       = new BusinessLayer <User>(new CapaNavDocDal());
            Equipment         equipment         = ebl.Get(model.EquipmentId.ToInt32());
            UserCallViewModel userCallViewModel = ubl.GetList().Select(u => u.ToUserCallViewModel()).FirstOrDefault(u => u.UserCall == model.SelectedUserCall);

            if (userCallViewModel == null)
            {
                return(Json(new { success = true }));
            }

            equipment.MonitoringUserId = userCallViewModel.UserId.ToInt32();
            equipment.MonitoringDate   = DateTime.ParseExact(model.Date, "dd-mm-yyyy", CultureInfo.InvariantCulture);
            ebl.Update(equipment);
            return(Json(new { success = true }));
        }
        public ActionResult UpdateMaintenanceDataMonitoring(MaintenanceDataMonitoringViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Users = new BusinessLayer <User>(new CapaNavDocDal()).GetList().Select(u => u.ToUserCallViewModel().UserCall).ToList();
                return(PartialView("MaintenanceDataMonitoringView", model));
            }

            BusinessLayer <MaintenanceData> mdbl = new BusinessLayer <MaintenanceData>(new CapaNavDocDal());
            BusinessLayer <User>            ubl  = new BusinessLayer <User>(new CapaNavDocDal());
            MaintenanceData   md = mdbl.Get(model.MaintenanceDataId.ToInt32());
            UserCallViewModel userCallViewModel = ubl.GetList().Select(u => u.ToUserCallViewModel()).FirstOrDefault(u => u.UserCall == model.SelectedUserCall);

            if (userCallViewModel == null)
            {
                return(Json(new { success = true }));
            }

            md.MonitoringUserId = userCallViewModel.UserId.ToInt32();
            md.MonitoringDate   = DateTime.ParseExact(model.Date, "dd-mm-yyyy", CultureInfo.InvariantCulture);
            mdbl.Update(md);
            return(Json(new { success = true }));
        }