Esempio n. 1
0
        public async Task <IActionResult> PutChannel(int id, Channel channel)
        {
            if (id != channel.ChannelId)
            {
                return(BadRequest());
            }

            _context.Entry(channel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChannelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Clear(Mob mob)
        {
            context.Spots.RemoveRange(context.Spots.Where(s => s.Monster.MonsterId == mob.MonsterId));

            await context.SaveChangesAsync();

            return(Ok("Ok"));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("ActTypeDescrip,ActTypeProd")] ActivityType activityType)
        {
            activityType.Username = User.Identity.Name;

            if (ModelState.IsValid)
            {
                _context.Add(activityType);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(activityType));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("ActivityName,ActivityTypeID")] Activity activity)
        {
            activity.Username = User.Identity.Name;

            if (ModelState.IsValid)
            {
                _context.Add(activity);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ActivityTypeID"] = new SelectList(_context.ActivityTypes.Where(o => o.Username == User.Identity.Name), "ActivityTypeID", "ActTypeDescrip", activity.ActivityTypeID);
            return(View(activity));
        }
        public async Task <IActionResult> Create([Bind("ActivityID,StartTime,EndTime")] TimeLog timeLog)
        {
            timeLog.Username = User.Identity.Name;

            if (ModelState.IsValid)
            {
                _context.Add(timeLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ActivityID"] = new SelectList(_context.Activities.Where(o => o.Username == User.Identity.Name), "ActivityID", "ActivityName", timeLog.ActivityID);
            return(View(timeLog));
        }
Esempio n. 6
0
        public async Task <IActionResult> Create([Bind("ActivityID")] TimeLog timeLog)
        {
            if (ModelState.IsValid)
            {
                //get last time log with no end time
                string query = "SELECT TOP 1 * FROM TimeLog WHERE Username = {0} and EndTime is null order by StartTime desc";
                try {
                    var endTimeLog = await _context.TimeLogs
                                     .FromSql(query, User.Identity.Name)
                                     .AsNoTracking()
                                     .SingleOrDefaultAsync();

                    if (endTimeLog != null)
                    {
                        endTimeLog.EndTime = DateTime.Now;
                        _context.Update(endTimeLog);
                        await _context.SaveChangesAsync();
                    }
                } catch (DbUpdateConcurrencyException) {
                    if (!TimeLogExists(timeLog.TimeLogID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                try {
                    timeLog.Username  = User.Identity.Name;
                    timeLog.StartTime = DateTime.Now;
                    _context.Add(timeLog);
                    await _context.SaveChangesAsync();
                } catch {
                }
                return(RedirectToAction("Index"));
            }
            ViewData["ActivityID"] = new SelectList(_context.Activities, "ActivityID", "ActivityID", timeLog.ActivityID);
            return(View(timeLog));
        }