public JsonInstitute InstituteList() { JsonInstitute jsonInstitute = new JsonInstitute(); InstituteViewModel instituteListObj = new InstituteViewModel(); List <InstituteViewModel> institutesLinkListObj = new List <InstituteViewModel>(); try { var instituteLists = _place.PlacesInstitute(); foreach (var item in instituteLists) { instituteListObj.Logo = _links.FindById(item.Id).Icon; instituteListObj.Title = _links.FindById(item.Id).Title; instituteListObj.Description = _links.FindById(item.Id).Description; instituteListObj.WebUrl = _links.FindById(item.Id).Url; instituteListObj.Phone = item.PhoneNumber; instituteListObj.CatagoriId = item.CategoryId; instituteListObj.AddressId = _address.FindById(item.AdressId).Detail; instituteListObj.LocationX = _address.FindById(item.AdressId).LocationX; instituteListObj.LocationY = _address.FindById(item.AdressId).LocationY; instituteListObj.LocationR = _address.FindById(item.AdressId).LocationR; institutesLinkListObj.Add(instituteListObj); } jsonInstitute.Result = institutesLinkListObj; return(jsonInstitute); } catch (Exception ex) { _ = ex.Message; return(jsonInstitute); } }
public ActionResult UpdateInstitude(InstituteViewModel ins, int id) { DB_Entities db = new DB_Entities(); var institite = db.Institutes.Where(x => x.Id == id).FirstOrDefault(); institite.Name = ins.Title; db.SaveChanges(); Alerts.InstitudeUpdated = true; return(RedirectToAction("ViewInstitude", "DashBoard")); }
// GET: Institutes/Create public IActionResult Create() { var universities = _context.Universities.ToList(); var model = new InstituteViewModel() { Universities = universities, }; return(View(model)); }
// GET: Institute/Details/5 public ActionResult Details(int id) { string markers = "["; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:18080/IRMCJEE-web/IRMC/"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage httpResponseMessage = client.GetAsync("institute").Result; if (httpResponseMessage.IsSuccessStatusCode) { ViewBag.result = httpResponseMessage.Content.ReadAsAsync <IEnumerable <InstituteViewModel> >().Result; foreach (var item in ViewBag.result) { InstituteViewModel instViewModel = new InstituteViewModel(); if (item.id_inst == id) { instViewModel.name = item.name; instViewModel.sigle = item.sigle; instViewModel.id_inst = item.id_inst; instViewModel.description = item.description; instViewModel.type = item.type; instViewModel.type_acces = item.type_acces; instViewModel.image = item.image; instViewModel.website = item.website; instViewModel.mail = item.mail; instViewModel.address = item.address; instViewModel.code_postale = item.code_postale; list.Add(instViewModel); markers += "{"; markers += string.Format("'title' : '{0}',", item.name); markers += string.Format("'lat' : '{0}',", item.latitude); markers += string.Format("'lng' : '{0}',", item.longitude); markers += string.Format("'description': '{0}',", item.description); markers += "},"; } } markers += "];"; ViewBag.Markers = markers; } else { ViewBag.result = "error"; } ViewBag.Markers = markers; return(View(list)); }
public ActionResult Create(InstituteViewModel i) { try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:18080/IRMCJEE-web/IRMC/"); client.PostAsJsonAsync <InstituteViewModel>("institute", i).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode()); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <IActionResult> Create(InstituteViewModel model) { var institute = new Institute() { Code = model.Code, Name = model.Name, UniversityProvider = _context.Universities.Find(model.UniversityProviderId) }; if (ModelState.IsValid) { _context.Add(institute); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public ActionResult AddInstitude(InstituteViewModel inst) { DB_Entities db = new DB_Entities(); string userId = User.Identity.GetUserId(); var count = db.Institutes.Where(x => x.UserId == userId && x.Name == inst.Title).Count(); if (!(count > 0)) { db.Institutes.Add(new Institute() { Name = inst.Title, UserId = userId }); db.SaveChanges(); Alerts.InstitudeAdded = true; return(RedirectToAction("AddInstitude", "DashBoard")); } Alerts.Exist = true; return(RedirectToAction("AddInstitude", "DashBoard")); }