public string Delete(int id, int userId)
 {
     Console.WriteLine("MeetupModel.Delete : START");
     try
     {
         var context     = new SantanderChalengeContext();
         var res         = context.Meetups.SingleOrDefault(x => x.Id == id);
         var permissions = res.UserOrganizer == userId;
         if (permissions)
         {
             context.Remove(context.Meetups.Single(x => x.Id == id));
             context.SaveChanges();
             Console.WriteLine("MeetupModel.Delete : END");
             return("");
         }
         else
         {
             Console.WriteLine("MeetupModel.Cancel : END");
             return("Solo el Organizador puede realizar esta accion.");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("MeetupModel.Delete : ERROR : " + ex.Message);
         return(ex.Message);
     }
 }
Ejemplo n.º 2
0
 public string Delete(int id)
 {
     Console.WriteLine("UsersModel.Delete : START");
     try
     {
         SantanderChalengeContext context = new SantanderChalengeContext();
         context.Remove(context.Users.Single(x => x.Id == id));
         context.SaveChanges();
         Console.WriteLine("UsersModel.Delete : END");
         return("");
     }
     catch (Exception ex)
     {
         Console.WriteLine("UsersModel.Delete : ERROR : " + ex.Message);
         return(ex.Message);
     }
 }