public async Task <IActionResult> Edit(int id, [Bind("Id,LakeId,Year,Value")] Evaporation surfaceFlow)
        {
            if (id != surfaceFlow.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(surfaceFlow);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EvaporationExists(surfaceFlow.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(surfaceFlow));
        }
        public async Task <IActionResult> Create([Bind("Id,LakeId,Year,Value")] Evaporation surfaceFlow)
        {
            if (ModelState.IsValid)
            {
                _context.Add(surfaceFlow);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(surfaceFlow));
        }
示例#3
0
        /// <summary>
        /// Gets the average storage time for the time period. Calculated as mean volume divide by mean (sinks + outflow + evaporation)
        /// </summary>
        /// <param name="Start"></param>
        /// <param name="End"></param>
        /// <returns></returns>
        public TimeSpan GetStorageTime(DateTime Start, DateTime End)
        {
            if (!IsEmpty)
            {
                if (EndTime < End || StartTime > Start)
                {
                    throw new Exception("Cannot calculate storage time outside of the simulated period");
                }

                //Find the total outflow
                double d = Sinks.GetSiValue(Start, End);
                d += Outflow.GetSiValue(Start, End);
                //Evaporation is negative
                d += Evaporation.GetSiValue(Start, End);
                d += GroundwaterOutflow.GetSiValue(Start, End);

                return(TimeSpan.FromSeconds(StoredVolume.GetSiValue(Start, End) / d));
            }
            return(TimeSpan.Zero);
        }