예제 #1
0
 public static Protocol MapToDomainModel(ProtocolViewModel viewModel)
 {
     return(new Protocol()
     {
         Weather = viewModel.Weather,
         Description = viewModel.Description,
         DateOfIssue = viewModel.DateOfIssue,
         IsSuccessfull = viewModel.IsSuccessfull,
         Name = viewModel.Name,
         Proclamation = viewModel.Proclamation,
         ProtocolType = viewModel.ProtocolType,
     });
 }
예제 #2
0
        public IActionResult Update(ProtocolViewModel protocol)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                protocolService.UpdateProtocol(ProtocolMapper.MapToDomainModel(protocol));
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
예제 #3
0
        public ActionResult Edit(Event model)
        {
            if (ModelState.IsValid)
            {
                DataContext.Entry(model).State = EntityState.Modified;
                DataContext.SaveChanges();

                var curEvent = DataContext.Events.Include("EventType").Single(x => x.Id == model.Id);
                var context  = GlobalHost.ConnectionManager.GetHubContext <GameLogHub>();
                if (!curEvent.EventType.IsSystemEventType)
                {
                    var protocol = new ProtocolViewModel(DataContext, model.GameId);
                    var result   = RenderHelper.RenderPartialToString("_GameProtocol", protocol, ControllerContext);
                    context.Clients.All.showProtocol(result);
                }
                if (model.EventType.IsSignifForProtocol)
                {
                    var result = RenderHelper.RenderPartialToString("_SingleEvent", new EventViewModel(curEvent), ControllerContext);
                    context.Clients.All.updateSingleLog(model.Id, result);
                }
                return(RedirectToAction("Manage", new { gameId = model.GameId }));
            }

            var ev        = DataContext.Events.Single(x => x.Id == model.Id);
            var eventType = ev.EventType;
            var sport     = eventType.Sport;

            ViewBag.Sport = sport;

            var game    = ev.Game;
            var players = new List <SelectListItem>();

            game.GameParticipants.ForEach(
                x =>
                players.AddRange(
                    x.GameParticipantPlayers.Select(
                        z => new SelectListItem {
                Text = z.Player.Name, Value = z.Id.ToString()
            })));
            ViewBag.Players = players;
            return(View(model));
        }
예제 #4
0
        public ActionResult Create(Event model)
        {
            if (ModelState.IsValid)
            {
                model.Count = model.Count == 0 ? 1 : model.Count;
                DataContext.Events.Add(model);
                DataContext.SaveChanges();

                var curEvent = DataContext.Events.Include("GameParticipantPlayer").Include("EventType").Single(x => x.Id == model.Id);
                var context  = GlobalHost.ConnectionManager.GetHubContext <GameLogHub>();
                if (curEvent.EventType.IsSignifForProtocol)
                {
                    var result = RenderHelper.RenderPartialToString("_SingleEvent", new EventViewModel(curEvent), ControllerContext);
                    context.Clients.All.showEvent(result);
                }
                if (!curEvent.EventType.IsSystemEventType)
                {
                    var protocol = new ProtocolViewModel(DataContext, model.GameId);
                    var result   = RenderHelper.RenderPartialToString("_GameProtocol", protocol, ControllerContext);
                    context.Clients.All.showProtocol(result);
                }
            }
            return(GetEventEditor(model.EventTypeId, model.GameId));
        }
예제 #5
0
        public ActionResult Delete(int id)
        {
            var ev            = DataContext.Events.Include("EventType").Single(x => x.Id == id);
            var gameId        = ev.GameId;
            var isSystem      = ev.EventType.IsSystemEventType;
            var isSignificant = ev.EventType.IsSignifForProtocol;

            DataContext.Events.Remove(ev);
            DataContext.SaveChanges();

            var context = GlobalHost.ConnectionManager.GetHubContext <GameLogHub>();

            if (!isSystem)
            {
                var protocol = new ProtocolViewModel(DataContext, gameId);
                var result   = RenderHelper.RenderPartialToString("_GameProtocol", protocol, ControllerContext);
                context.Clients.All.showProtocol(result);
            }
            if (isSignificant)
            {
                context.Clients.All.updateSingleLog(id, "");
            }
            return(RedirectToAction("Manage", new { gameId }));
        }
예제 #6
0
        public ActionResult Protocol(int id = 0)
        {
            Result result = _dataManager.Results.GetResultById(id);

            if (result == null)
            {
                return(View("Error"));
            }

            Sample sample = _dataManager.Samples.GetSampleByNumber(result.SampleId);
            TechnicalRegulation techniqueOfTests =
                _dataManager.TechnicalRegulations.GetTechnicalRegulationById(result.TechniqueOfTestsId);
            Indicator       indicator       = _dataManager.Indicators.GetIndicatorById(result.IndicatorId);
            AdmissibleLevel admissibleLevel =
                _dataManager.AdmissibleLevels.GetAdmissibleLevelById(result.AdmissibleLevelId);
            TechnicalRegulation technicalRegulation =
                _dataManager.TechnicalRegulations.GetTechnicalRegulationById(admissibleLevel.TechnicalRegulationId);
            Gage      gage = _dataManager.Gages.GetGageById(result.GageId);
            Indicator temperatureIndicator =
                _dataManager.Indicators.GetIndicators().FirstOrDefault(x => x.Name == "температура");
            Indicator humidityIndicator =
                _dataManager.Indicators.GetIndicators().FirstOrDefault(x => x.Name == "влажность");
            Indicator pressureIndicator =
                _dataManager.Indicators.GetIndicators().FirstOrDefault(x => x.Name == "атмосферное давление");
            Indicator radiationIndicator =
                _dataManager.Indicators.GetIndicators().FirstOrDefault(x => x.Name == "мощность экспозиционной дозы");


            var model = new ProtocolViewModel
            {
                SampleId    = sample.RegistrationNumber,
                SampleName  = sample.Name,
                ResultDate  = result.ResultDate.ToShortDateString(),
                Applicant   = sample.Applicant,
                Temperature =
                    _dataManager.Conditions.GetConditions().FirstOrDefault(
                        x => x.ResultId == result.Id && x.IndicatorId == temperatureIndicator.Id).
                    ConditionValue,
                Humidity =
                    _dataManager.Conditions.GetConditions().FirstOrDefault(
                        x => x.ResultId == result.Id && x.IndicatorId == humidityIndicator.Id).
                    ConditionValue,
                Pressure =
                    _dataManager.Conditions.GetConditions().FirstOrDefault(
                        x => x.ResultId == result.Id && x.IndicatorId == pressureIndicator.Id).
                    ConditionValue,
                Radiation =
                    _dataManager.Conditions.GetConditions().FirstOrDefault(
                        x => x.ResultId == result.Id && x.IndicatorId == radiationIndicator.Id).
                    ConditionValue,
                TechniqueOfTestsDesignation = techniqueOfTests.Designation,
                TechniqueOfTestsName        = techniqueOfTests.Name,
                ResultValue = result.ResultValue,
                LevelValue  = admissibleLevel.LevelValue,
                Units       = indicator.Units,
                TechnicalRegulationDesignation = technicalRegulation.Designation,
                TechnicalRegulationName        = technicalRegulation.Name,
                GageName      = gage.Name,
                SerialNumber  = gage.SerialNumber,
                IndicatorName = indicator.Name
            };

            SelectedSample selectedSample =
                _dataManager.SelectedSamples.GetSelectedSampleByRegNumb(sample.RegistrationNumber);

            if (selectedSample != null)
            {
                TechnicalRegulation samplingTechnique =
                    _dataManager.TechnicalRegulations.GetTechnicalRegulationById(selectedSample.SamplingTechnique);
                model.Manufacturer = selectedSample.Manufacturer;
                model.SamplingDate = selectedSample.SamplingDate.ToShortDateString();
                model.SamplingTechniqueDesignation = samplingTechnique.Designation;
                model.SamplingTechniqueName        = samplingTechnique.Name;
            }
            else
            {
                model.Manufacturer = "-";
                model.SamplingDate = "-";
                model.SamplingTechniqueDesignation = "-";
                model.SamplingTechniqueName        = "";
            }

            return(View(model));
        }
예제 #7
0
 private static void CreateProtokolView()
 {
     if (_protorolView == null)
     {
         _protorolView = new ProtocolViewModel();
     }
 }
예제 #8
0
 public static void ClearProtokol()
 {
     _protorolView = null;
 }
예제 #9
0
        public ActionResult GetProtocol(int gameId)
        {
            var protocol = new ProtocolViewModel(DataContext, gameId);

            return(PartialView("_GameProtocol", protocol));
        }