public async Task <WorkDTO> DeleteAsync(long Id) { Work result = await _workRepository.Delete(Id); var work = _mapper.Map <Work, WorkDTO>(result); return(work); }
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")); }
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")); }
public void DeleteForm(string keyValue) { service.Delete(t => t.Id == keyValue); }
public async Task <IActionResult> DeleteTask(string id) { return(Ok(await _repository.Delete(id))); }
public bool Delete(string id) { return(_res.Delete(id)); }
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); }