Beispiel #1
0
 public Location(double value, EnumLocationType type)
 {
     int[] degmin = AstroUtility.GetDegreeMinuteSeconds(value);
     DegValue       = Math.Abs(degmin[0]);
     MinuteValue    = Math.Abs(degmin[1]);
     DirectionValue = this.ofVal(value, type);
 }
        public async Task <IActionResult> Edit(int id, [Bind("EnumLocationTypeId,Comment,Description,Timestamp,VersionNumber")] EnumLocationType val)
        {
            if (val.EnumLocationTypeId != id)
            {
                return(NotFound());
            }

            this.FixNullFields(val);

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(val);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Exists(val.EnumLocationTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(val));
        }
Beispiel #3
0
        public EnumDirection ofVal(double val, EnumLocationType type)
        {
            switch (type)
            {
            case EnumLocationType.Latitude: return(val < 0 ? EnumDirection.SOUTH : EnumDirection.NORTH);

            case EnumLocationType.Longitude: return(val < 0 ? EnumDirection.WEST : EnumDirection.EAST);
            }
            return(EnumDirection.NONE);
        }
 private void FixNullFields(EnumLocationType val)
 {
     if (String.IsNullOrWhiteSpace(val.Comment))
     {
         val.Comment = "N/A";
     }
     if (String.IsNullOrWhiteSpace(val.Description))
     {
         val.Description = "N/A";
     }
 }
        public async Task <IActionResult> Create([Bind("EnumLocationTypeId,Comment,Description,Timestamp,VersionNumber")] EnumLocationType val)
        {
            this.FixNullFields(val);
            if (ModelState.IsValid)
            {
                _context.Add(val);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(val));
        }