Ejemplo n.º 1
0
        public async Task <WorkDTO> DeleteAsync(long Id)
        {
            Work result = await _workRepository.Delete(Id);

            var work = _mapper.Map <Work, WorkDTO>(result);

            return(work);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> StopWork()
        {
            var user = await _userManager.GetUserAsync(User);

            user.Status = UserStatus.Stays;
            await _userManager.UpdateAsync(user);

            _workRepository.Delete(user.Id);

            return(RedirectToAction("Work"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> DeleteWork(int userId, int id)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var workFromRepo = await _repo.GetWork(id);

            _repo.Delete(workFromRepo);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Failed to delete"));
        }
Ejemplo n.º 4
0
 public void DeleteForm(string keyValue)
 {
     service.Delete(t => t.Id == keyValue);
 }
Ejemplo n.º 5
0
 public async Task <IActionResult> DeleteTask(string id)
 {
     return(Ok(await _repository.Delete(id)));
 }
Ejemplo n.º 6
0
 public bool Delete(string id)
 {
     return(_res.Delete(id));
 }
Ejemplo n.º 7
0
        public async Task InvokeAsync(HttpContext context, UserManager <ApplicationUser> userManager,
                                      IWorkRepository workRepository, ITavernRepository tavernRepository,
                                      ITripRepository tripRepository, ILocationRepository locationRepository)
        {
            if (context.User.Identity.IsAuthenticated)
            {
                var user = await userManager.GetUserAsync(context.User);

                //Check Work
                if (user.Status == UserStatus.Work)
                {
                    var work = workRepository.GetWork(user.Id);

                    if (DateTime.UtcNow >= work.End)
                    {
                        var location = locationRepository.GetLocations()
                                       .Where(loc => loc.X == user.PositionX)
                                       .Where(loc => loc.Y == user.PositionY)
                                       .SingleOrDefault();

                        user.ExperiencePoints += work.Hours * location.Experience;
                        user.AllExperience    += work.Hours * location.Experience;
                        user.ActionPoints     -= work.Hours;
                        user.Gold             += work.Hours * location.Gold;
                        user.Status            = UserStatus.Stays;
                        await userManager.UpdateAsync(user);

                        workRepository.Delete(user.Id);
                    }
                }

                //Check Tavern
                if (user.Status == UserStatus.Tavern)
                {
                    var tavern = tavernRepository.GetTavern(user.Id);

                    if (DateTime.UtcNow >= tavern.End)
                    {
                        user.ActionPoints += (int)(tavern.Hours * 2);
                        user.Gold         -= (int)(tavern.Hours * 10);
                        user.Status        = UserStatus.Stays;
                        await userManager.UpdateAsync(user);

                        tavernRepository.Delete(user.Id);
                    }
                }

                //Check Trip
                if (user.Status == UserStatus.Trip)
                {
                    var trip = tripRepository.GetTrip(user.Id);

                    if (DateTime.UtcNow >= trip.End)
                    {
                        user.PositionX = trip.X;
                        user.PositionY = trip.Y;
                        user.Status    = UserStatus.Stays;
                        await userManager.UpdateAsync(user);

                        tripRepository.Delete(user.Id);
                    }
                }

                //Add Level
                if (user.ExperiencePoints >= user.MaxExperiencePoints && user.Level < 100)
                {
                    user.ExperiencePoints   -= user.MaxExperiencePoints;
                    user.MaxExperiencePoints = (int)(user.MaxExperiencePoints * 1.2);
                    user.Level++;
                    user.SkillPoints += 3;
                    user.HealthPoints = user.MaxHealthPoints;
                    await userManager.UpdateAsync(user);
                }
            }

            await _next(context);
        }