Esempio n. 1
0
        public IHttpActionResult CreateLogin([FromBody] Signup signup)
        {
            Console.Write(signup);
            using (var context = new TasteContext())
            {
                if (context.Admins.Where(a => a.Username.Equals(signup.username)).ToList().Count() > 0)
                {
                    return(Unauthorized());
                }

                context.Admins.Add(new Admins()
                {
                    Username       = signup.username,
                    Password       = signup.password,
                    RestaurantName = signup.name
                });

                var res = context.Restaurants.ToList();
                context.Restaurants.Add(new Restaurant()
                {
                    CloverId     = signup.cloverId,
                    Name         = signup.name,
                    Location     = signup.location,
                    Phone        = signup.phone,
                    Owner        = signup.owner,
                    Image        = "",
                    AccessToken  = signup.accessToken,
                    ExchangeRate = 6.5,
                    IsSandbox    = false
                });
                context.SaveChanges();
            }

            return(Json("Success"));
        }
Esempio n. 2
0
 public IHttpActionResult CheckIfCloverUserExists([FromBody] Signup signup)
 {
     using (var context = new TasteContext())
     {
         if (context.Admins.Where(a => a.Username.Equals(signup.username)).ToList().Count() > 0)
         {
             return(Json("Exist"));
         }
         else
         {
             return(Json("Doesn't exist"));
         }
     }
 }