// GET: deals public ActionResult createDeal() { var context = new promoLacDbEntities(); var y = context.dealCategories.ToList(); dealsModel x = new dealsModel(); x.dealCategoryLists = y; return(View(x)); }
public ActionResult createDeal(dealsModel d, HttpPostedFileBase dealsImage) { string path = uploadimage(dealsImage); var context = new promoLacDbEntities(); deal obj = new deal(); obj.vendorId = getvendorId(User.Identity.Name); HttpClient httpClient = new HttpClient(); string baseUrl = "https://localhost:44371/"; string path1 = "C:\\Users\\DELL\\source\\repos\\fypPromolac\\fypPromolac\\Content\\images\\53757052inam-picture.jpeg"; HttpResponseMessage response = httpClient.GetAsync(baseUrl + "api2/fileFirebase/GetFileUpload?id=" + path + "&vId=" + obj.vendorId + "&fileName=" + dealsImage.FileName).Result; string stateInfo = response.Content.ReadAsStringAsync().Result; stateInfo = stateInfo.Substring(1, stateInfo.Count() - 2); obj.dealCategory = getDealCategoryId(d.dealCategory); obj.dealDescription = d.dealDescription; obj.dealName = d.dealName; obj.dealPrice = d.dealPrice; obj.latitude = d.latitude; obj.longitude = d.longitude; obj.dealImage = path; obj.dealTime = DateTime.Now.Date; obj.area = d.AreaName; context.deals.Add(obj); context.SaveChanges(); tempDeal ddd = new tempDeal(); ddd.dealimg = stateInfo; ddd.dealprice = d.dealPrice.ToString(); ddd.latitude = d.latitude.ToString(); ddd.longitute = d.longitude.ToString(); ddd.rating = 2.ToString(); ddd.dealtitle = d.dealName; IFirebaseConfig mes = new FirebaseConfig { AuthSecret = "CwnE0VGXMqxNxcY5YSWVNcL7IAM3hfqRuSiNjWm5", BasePath = "https://xdadeveloperes.firebaseio.com/" }; IFirebaseClient mfc; mfc = new FireSharp.FirebaseClient(mes); var data = ddd; PushResponse r = mfc.Push(d.dealCategory + "/", data); return(Json(new { success = true, message = "dddd" }, JsonRequestBehavior.AllowGet)); }