public ActionResult Create(vendorModel user) { using (var context = new promoLacDbEntities()) { { vendor info = new vendor() { firstName = user.firstName, lastName = user.lastName, vendorEmail = user.vendorEmail, vendorPassword = user.vendorPassword, registerTimestamp = DateTime.Now, phoneNumber = user.phoneNumber, vendorUserName = user.vendorUserName, headId = vendorId(User.Identity.Name), isHead = "N", vendorStatus = "A", vendorAddress = vendorAddress(vendorId(User.Identity.Name)), vendorCompanyName = vendorCompanyName(vendorId(User.Identity.Name)) }; context.vendors.Add(info); context.SaveChanges(); var result = context.userPackages.Where(x => x.vendorId == info.headId).FirstOrDefault(); userPackage u = new userPackage(); u.vendorId = vendorId(user.vendorUserName); u.packageStartTime = result.packageStartTime; u.packageEndTime = result.packageEndTime; u.packageId = result.packageId; u.dividedShareOfMessages = user.messagesAllowed; u.packageStatus = "active"; u.notificationSent = 0; u.remainingFencingHours = user.fencingHours; context.userPackages.Add(u); context.SaveChanges(); foreach (var x in user.areas) { areaAssigned ar = new areaAssigned() { vendorId = vendorId(user.vendorUserName), areaId = Convert.ToInt32(x) }; context.areaAssigneds.Add(ar); context.SaveChanges(); } var result1 = context.userPackages.Where(x => x.vendorId == info.headId).FirstOrDefault(); result1.dividedShareOfMessages = result1.dividedShareOfMessages - user.messagesAllowed; result1.remainingFencingHours = result1.remainingFencingHours - user.fencingHours; context.SaveChanges(); } return(RedirectToAction("../ControlPanel/ControlPanel")); } }
public ActionResult createPackage(packageModel pckg) { using (var context = new promoLacDbEntities()) { package p = new package(); p.packageName = pckg.packageName; p.packageDescription = pckg.packageDescription; p.packageDurationDays = pckg.packageDurationDays; p.subUsersAllowed = pckg.subUsersAllowed; context.packages.Add(p); context.SaveChanges(); List <packageModel> package_List = new List <packageModel>(); package_List = context.packages.Select(x => new packageModel { packageName = x.packageName, packagesId = x.packagesId, packageDescription = x.packageDescription, packageDurationDays = x.packageDurationDays, messagesAllowed = x.messagesAllowed, subUsersAllowed = x.subUsersAllowed }).ToList(); return(View("viewAllPackage", package_List)); } }
public ActionResult editPackage(packageModel pck) { using (var context = new promoLacDbEntities()) { var myresult = context.packages.Where(x => x.packagesId == pck.packagesId).First(); myresult.packageName = pck.packageName; myresult.packageDescription = pck.packageDescription; myresult.messagesAllowed = pck.messagesAllowed; myresult.packageDurationDays = pck.packageDurationDays; context.SaveChanges(); List <packageModel> package_List = new List <packageModel>(); package_List = context.packages.Select(x => new packageModel { packageName = x.packageName, packagesId = x.packagesId, packageDescription = x.packageDescription, packageDurationDays = x.packageDurationDays, messagesAllowed = x.messagesAllowed, subUsersAllowed = x.subUsersAllowed }).ToList(); return(View("viewAllPackage", package_List)); } }
public ActionResult login(vendorModel model) { using (var context = new promoLacDbEntities()) { bool isvalidVendor = context.vendors.Any(x => x.vendorUserName == model.vendorUserName && x.vendorPassword == model.vendorPassword); if (isvalidVendor) { FormsAuthentication.SetAuthCookie(model.vendorUserName, false); int id = vendorId(model.vendorUserName); var result = context.userPackages.Where(x => x.vendorId == id).FirstOrDefault(); int comp = DateTime.Compare(result.packageEndTime, DateTime.Now); if (comp < 0) { result.packageStatus = "NotActive"; context.SaveChanges(); ModelState.AddModelError("", "Package Expired"); } else { return(RedirectToAction("controlPanel", "controlPanel")); } } else { ModelState.AddModelError("", "Invalid User Name and Password"); } } return(View()); }
public void updateFencingHours(int id, int hr) { var context = new promoLacDbEntities(); var result = context.userPackages.Where(x => x.vendorId == id).FirstOrDefault(); result.remainingFencingHours = result.remainingFencingHours - hr; result.fenceCreated = result.fenceCreated + 1; context.SaveChanges(); }
public ActionResult AddCompleteVendorInfo(vendorViewModel v) { vendorViewModel v1 = TempData["vendorObject"] as vendorViewModel; v1.vendorPackageTaken = v.vendorPackageTaken; using (var context = new promoLacDbEntities()) { vendor ven = new vendor() { firstName = v1.firstName, lastName = v1.lastName, phoneNumber = v1.phoneNumber, vendorEmail = v1.vendorEmail, vendorAddress = v1.vendorAddress, registerTimestamp = DateTime.Now, vendorUserName = v1.vendorUserName, vendorPassword = v1.vendorPassword, vendorBirthDate = DateTime.Now, vendorStatus = "A", vendorAdminId = getAdminId(User.Identity.Name), vendorPackageTaken = v1.vendorPackageTaken, isAdmin = v1.isAdmin, vendorCompanyName = v1.vendorCompanyName }; context.vendors.Add(ven); context.SaveChanges(); int id = getVendorId(v1.vendorUserName); foreach (var item in v1.area_vendor) { areaAssigned ar = new areaAssigned() { vendorId = id, areaId = Convert.ToInt32(item) }; context.areaAssigneds.Add(ar); context.SaveChanges(); } return(RedirectToAction("viewAllVendors")); } }
public ActionResult updateVendorPackage(vendorViewModel v) { using (var context = new promoLacDbEntities()) { var result = context.vendors.Where(x => x.vendorId == v.vendorId).FirstOrDefault(); result.vendorPackageTaken = v.vendorPackageTaken; context.SaveChanges(); return(View("viewAllVendors")); } }
public void removeArea(int area_id, int vendor_id) { using (var context = new promoLacDbEntities()) { var myresult = context.areaAssigneds.Where(x => (x.areaId == area_id) && (x.vendorId == vendor_id)).First(); context.areaAssigneds.Remove(myresult); context.SaveChanges(); } EditVendor(vendor_id); }
public ActionResult changePassword(passwordChange p) { using (var context = new promoLacDbEntities()) { var myresult = context.vendors.Where(x => x.vendorUserName == User.Identity.Name).First(); myresult.vendorPassword = p.newPassword; context.SaveChanges(); return(RedirectToAction("../ControlPanel/ControlPanel")); } }
// POST: userInfoes/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] /* public ActionResult Edit(user u) * { * * * * using (var context = new userAuthenticationEntities()) * { * user details = new user(); * var myresult = context.userInfo.Where(x => x.userAdmin == User.Identity.Name).Select(x => new user() * { * * userId = x.userId, * userName = x.userName, * * }).ToList(); * * * foreach (user x in myresult) * { * x.detail = Getarea(x.userId); * x.m_Allowed = mesallowed(x.userId); * x.m_sent = messent(x.userId); * * } * return View(myresult); * * } * * * * * * * /*if (ModelState.IsValid) * { * * db.Entry(u).State = EntityState.Modified; * db.SaveChanges(); * return RedirectToAction("Index"); * } * return View(u); * }*/ public ActionResult RemoveArea(string areaa, int id) { using (var context = new promoLacDbEntities()) { int area_Id = getAreaId(areaa); var myresult = context.areaAssigneds.Where(x => (x.areaId == area_Id) && (x.vendorId == id)).First(); //.Where(o=>(o.areaId == id )&&(o.areaName==areaa)).SingleOrDefault(); context.areaAssigneds.Remove(myresult); context.SaveChanges(); return(RedirectToAction("../ControlPanel/ControlPanel")); } }
public ActionResult Addarea(areaAssignedModel u) { using (var context = new promoLacDbEntities()) { areaAssigned a = new areaAssigned() { vendorId = u.vendorId, areaId = 1 }; context.areaAssigneds.Add(a); context.SaveChanges(); } return(RedirectToAction("../controlPanel/controlPanel")); }
public void updatemessagesent() { using (var context = new promoLacDbEntities()) { int id = vendorId(User.Identity.Name); var message = context.userPackages.FirstOrDefault(x => x.vendorId == id); if (message != null) { message.notificationSent++; } context.SaveChanges(); } }
public ActionResult createFence(fenceModel f) { tempFence tf = new tempFence(); tf.Latitude = f.latitude.ToString(); tf.Longitude = f.longitude.ToString(); tf.Notification_ = f.notification; tf.TimeStamp = DateTime.Now.AddHours(f.hr).ToString("MM/dd/yyyy HH:mm:ss"); tf.Radius = f.radius.ToString(); IFirebaseConfig mes = new FirebaseConfig { AuthSecret = "CwnE0VGXMqxNxcY5YSWVNcL7IAM3hfqRuSiNjWm5", BasePath = "https://xdadeveloperes.firebaseio.com/" }; IFirebaseClient mfc; mfc = new FireSharp.FirebaseClient(mes); var data = tf; PushResponse r = mfc.Push("Fences_" + "/", data); updateFencingHours(Convert.ToInt32(f.vendorId), f.hr); var context = new promoLacDbEntities(); fence fence_ = new fence(); fence_.latitude = f.latitude; fence_.longitude = f.longitude; fence_.startTime = DateTime.Now; fence_.endTime = DateTime.Now.AddHours(f.hr); fence_.notification = f.notification; fence_.radius = f.radius; fence_.vendorId = f.vendorId; fence_.area = f.AreaName; context.fences.Add(fence_); context.SaveChanges(); return(Json(new { success = true, message = "dddd" }, JsonRequestBehavior.AllowGet)); }
public ActionResult createMessage(messageModel m) { var context = new promoLacDbEntities(); messages_ obj = new messages_(); foreach (var x in m.areaName) { obj.vendorID = m.vendorID; obj.messageDescription = m.messageDescription; obj.messageTitle = m.messageTitle; obj.areaId = getAreaId(x); obj.messageStatus = "s"; context.messages_.Add(obj); context.SaveChanges(); tempMessage objM = new tempMessage(); objM.notificationStatus = "s"; objM.notificationAreaId = obj.areaId.ToString(); objM.notificationDescription = obj.messageDescription; objM.notificationTitle = obj.messageTitle; objM.notificationTime = DateTime.Now.ToString(); objM.notificationId = obj.messageId.ToString(); IFirebaseConfig mes = new FirebaseConfig { AuthSecret = "CwnE0VGXMqxNxcY5YSWVNcL7IAM3hfqRuSiNjWm5", BasePath = "https://xdadeveloperes.firebaseio.com/" }; IFirebaseClient mfc; mfc = new FireSharp.FirebaseClient(mes); var set = mfc.Set(@"Messages/" + obj.messageId, objM); } return(Json(new { success = true, message = "dddd" }, JsonRequestBehavior.AllowGet)); }
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)); }
public ActionResult notify(notificationModel n) { //string path = uploadimage(notimage); using (var context = new promoLacDbEntities()) { if (ModelState.IsValid) { { foreach (var x in n.areaName) { notification not = new notification() { notificationTitle = n.notificationTitle, notificationDescription = n.notificationDescription, notificationAreaId = getAreaId(x), notificationStatus = "s", vendorId = n.vendorId, notificationTime = DateTime.Now }; string towards = getHashCode(not.notificationAreaId); context.notifications.Add(not); updatemessagesent(); context.SaveChanges(); string SERVER_API_KEY = "AAAAtlCjlu4:APA91bGGwQ8HSMWLf7dVoD3c1XB3O7IBmhet0im9YCbFuxDF5pVui8IBZ8iCXcnUv2K32XVLnoAFwU17CdeYs3SGW6IX01dKeRSXAht8cS7WPg21fU_WIrkX8o-1FpWyQjlPxFj_mp8R"; var SENDER_ID = "783036946158"; WebRequest tRequest; tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send"); tRequest.Method = "post"; tRequest.ContentType = "application/json"; tRequest.Headers.Add(string.Format("Authorization: key={0}", SERVER_API_KEY)); tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID)); var data = new { notification = new { body = not.notificationDescription, title = not.notificationTitle } , to = "/topics/" + towards }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(data); //logger.Info("json: " + json); Byte[] byteArray = Encoding.UTF8.GetBytes(json); tRequest.ContentLength = byteArray.Length; Stream dataStream = tRequest.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse tResponse = tRequest.GetResponse(); dataStream = tResponse.GetResponseStream(); StreamReader tReader = new StreamReader(dataStream); String sResponseFromServer = tReader.ReadToEnd(); tReader.Close(); dataStream.Close(); tResponse.Close(); /* notificationModel nt = new notificationModel(); * nt.notificationAreaId = not.notificationAreaId.ToString(); * nt.notificationDescription = n.notificationDescription; * nt.notificationId = not.notificationId.ToString(); * nt.notificationStatus = "s"; * nt.notificationTitle = n.notificationTitle; * * * * IFirebaseConfig mes = new FirebaseConfig * { * AuthSecret = "CwnE0VGXMqxNxcY5YSWVNcL7IAM3hfqRuSiNjWm5", * BasePath = "https://xdadeveloperes.firebaseio.com/" * }; * * IFirebaseClient mfc; * mfc = new FireSharp.FirebaseClient(mes); * * var set = mfc.Set(@"Messages/" + not.notificationId, nt); */ } } } } return(Json(new { success = true, message = "dddd" }, JsonRequestBehavior.AllowGet)); }