public JsonResult Register(string phone, string pwd, string name, string city) { try { if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(pwd) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(city)) return Json(new { Error = "Invalid input", status = 405 }, JsonRequestBehavior.AllowGet); var foodProvider = new FoodProviderModel() { Id = phone, City = city.ToLower(), Longititde = 77.391F, Latitude = 28.5355F, Name = name, Password = pwd }; IHomeFoodRepository repo = new HomeFoodRepository(); repo.RegisterFoodProvider(foodProvider); return Json(new { status = 200 }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Error = ex.Message, status = 400 }, JsonRequestBehavior.AllowGet); } }
public void RegisterFoodProvider(FoodProviderModel foodProvider) { _homeFoodDB.GetCollection<FoodProviderModel>(Collections.FoodProviderCollection).InsertOneAsync(foodProvider); }