Esempio n. 1
0
 public ActionResult ShareList(FormCollection collection)
 {
     try
     {
         var             emailAddress    = collection["EmailAddress"];
         var             type            = int.Parse(collection["Type"]);
         var             listId          = int.Parse(collection["ShoppingList_Id"]);
         UserService     userService     = new UserService();
         var             userId          = userService.GetIdByEmail(emailAddress);
         ShoppingListDto shoppingListDto = new ShoppingListDto
         {
             UserId           = userId,
             Id               = listId,
             ListAccessTypeId = type
         };
         ShoppingListService listService = new ShoppingListService();
         listService.CreateLink(shoppingListDto);
         TempData["SuccessMessage"] = "You successfully shared your list!";
         return(RedirectToAction("SingleList", new { @id = listId }));
     }
     catch
     {
         var listId = int.Parse(collection["ShoppingList_Id"]);
         TempData["ErrorMessage"] = "An error occured and your list hasn't been shared.";
         return(RedirectToAction("SingleList", new { @id = listId }));
     }
 }