/// <summary> /// Feed a pet. Saves this action on the database (Actions table) and decreases the hunger value of a UserPet. /// </summary> /// <param name="userPetId">Id of the UserPet</param> /// <returns>Updated object of the UserPet</returns> public async Task <UserPet> FeedPet(int userPetId) { var userPet = await userPetRepo.GetUserPet(userPetId); if (userPet == null) { Console.WriteLine($"{nameof(UserPetService)} - FeedPet - User Pet is null."); return(null); } await actionService.CreateAction(ActionTypeEnum.Feed, userPet); return(await UpdatePetStatus(userPet, Configuration.FeedingValue, 0)); }
public ActionResult Reactivate(FormCollection Fc) { Client ToReactivate = ClientService.GetClientByNameAndMail(Fc["ClientName"], Fc["ContactMail"]); ToReactivate.IsDeleted = false; ToReactivate.Status = "On Hold"; ToReactivate.Expiry = null; ToReactivate.IsExpiryNull = true; var i = 0; foreach (var Sub in ToReactivate.ClientSubscriptions) { ToReactivate.ClientSubscriptions.ElementAt(i).IsDeleted = false; i++; } try { ClientService.EditClient(ToReactivate); } catch (DbUpdateException ex) { TempData["ReActivateError"] = "Error in Readding the client again.."; return(RedirectToAction("Create", new { ResellerID = ToReactivate.ResellerID })); } HubManPractices.Models.Action Reactivate = new HubManPractices.Models.Action() { ActionID = Guid.NewGuid(), ActionName = "ReAactivated", Client = ToReactivate, Date = DateTime.Now }; ActionService.CreateAction(Reactivate); TempData["ReactivateClient"] = "The Client has been Reactivated"; return(RedirectToAction("Index", new { ResellerID = ToReactivate.ResellerID })); }