public ActionResult Save(
            EditMode editMode, string id,
            DateTime?positionDateTime, string comment, double?latitude, double?longitude)
        {
            var positionReport = GetPositionReport(editMode, id);

            positionReport.PositionDateTime = positionDateTime;
            positionReport.Comment          = comment;

            if (latitude != null && longitude != null)
            {
                positionReport.Position = new Position(latitude.Value, longitude.Value);
            }

            if (!ModelState.IsValid)
            {
                var editData = new EditPositionReportData
                {
                    EditMode       = editMode,
                    PositionReport = positionReport
                };

                return(View("Edit", editData));
            }

            if (editMode == EditMode.Add)
            {
                _positionReportRepository.Save(positionReport);
            }

            _positionReportRepository.SubmitChanges();

            return(RedirectToAction("Index"));
        }
示例#2
0
        private static string CreatePositionReport(IPositionReportRepository repository, string comment, DateTime dateTime, float latitude, float longitude)
        {
            var positionReport = repository.Create();

            positionReport.Comment          = comment;
            positionReport.PositionDateTime = dateTime;
            positionReport.Position         = new Position(latitude, longitude);

            repository.Save(positionReport);

            repository.SubmitChanges();

            return(positionReport.ID);
        }
        public override void ProcessMessage(ParsedMessage parsedMessage)
        {
            base.ProcessMessage(parsedMessage);

            var positionReport = _positionReportRepository.Create();

            positionReport.Comment = parsedMessage["COMMENT"] ?? "";

            SetPosition(parsedMessage, positionReport);

            _positionReportRepository.Save(positionReport);

            _positionReportRepository.SubmitChanges();
        }