public IHttpActionResult DeleteUser(int Id)
 {
     try
     {
         using (ReactNativeSampleEntities db = new ReactNativeSampleEntities())
         {
             var hobbies = db.UserHobbiesMappings.Where(x => x.UserId == Id).ToList();
             foreach (var hobby in hobbies)
             {
                 db.UserHobbiesMappings.Remove(hobby);
             }
             var user = db.Users.Find(Id);
             db.Users.Remove(user);
             db.SaveChanges();
             return(Ok());
         }
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, "An error occured, please try again later"));
     }
 }
        public IHttpActionResult AddUser()
        {
            try
            {
                using (ReactNativeSampleEntities db = new ReactNativeSampleEntities())
                {
                    var form    = HttpContext.Current.Request.Form;
                    var hobbies = JsonConvert.DeserializeObject <List <Hobbies> >(form.Get("selectedHobbies"));

                    User user = new User();

                    user.FirstName = form.Get("firstName");
                    user.LastName  = form.Get("lastName");
                    user.Email     = form.Get("email");
                    user.Country   = Convert.ToInt32(form.Get("country"));
                    user.Gender    = form.Get("gender");
                    user.DOB       = Convert.ToDateTime(form.Get("dob"));

                    for (int i = 0; i < hobbies.Count(); i++)
                    {
                        UserHobbiesMapping hobby = new UserHobbiesMapping();

                        hobby.HobbyId = hobbies[i].value;
                        user.UserHobbiesMappings.Add(hobby);
                    }

                    db.Users.Add(user);
                    db.SaveChanges();

                    return(Ok());
                }
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, "An error occcured, please try again later"));
            }
        }