// Edit Suggestion Page // GET: Suggestion/Edit/5 public ActionResult Edit(int?id) { if ((HttpContext.Session.GetString("Role") == null) || (HttpContext.Session.GetString("Role") != "Lecturer")) { return(RedirectToAction("Index", "Home")); } if (id == null) { return(RedirectToAction("Index")); } //gets the suggestion information based on the URL ID Suggestion suggestion = suggestionContext.GetSuggestionDetails(id.Value); //if the suggestion cannot be found, return null and return a message to the index action if (suggestion == null) { TempData["Message"] = "The Suggestion does not exist!"; return(RedirectToAction("Index")); } //if the suggestion's lecturer id does not match with the logged in lecturer's ID if (suggestion.LecturerId != Convert.ToInt32(HttpContext.Session.GetString("ID"))) { TempData["Message"] = "You are not allowed to edit other lecturer's suggestion!"; return(RedirectToAction("Index")); } //if all validations are ok, return the page with the suggestion mapped properly with proper fields SuggestionViewModel suggestionVM = MapToStudentVM(suggestion); return(View(suggestionVM)); }
//skickar in en model, med tiden man har valt. public async Task <ActionResult> TimeBooked(DateTime date, DateTime startTime, DateTime endTime, int articleId) { var bookingSystem = await new ArticleController().GetBookingSystemFromArticle(articleId); var bookingTable = new BookingTableEntity { ArticleId = articleId, Date = date, StartTime = startTime, EndTime = endTime, BookingSystemId = bookingSystem.BookningSystemId }; await Task.Run(() => AddBooking(bookingTable)); var suggestionViewModel = new SuggestionViewModel(); suggestionViewModel.ListOfSuggestionsFromDifferentBookingSystems = await GetSuggestionsFromDifferentBookingSystems(bookingTable); suggestionViewModel.Article = await new ArticleRepo().GetArticleAsync(articleId); suggestionViewModel.BookingTable = bookingTable; suggestionViewModel.ListOfSuggestionsFromSameBookingSystems = await GetSuggestionsFromSameBookingSystem(bookingTable); suggestionViewModel.BookingSystem = bookingSystem; return(View(suggestionViewModel)); }
// Delete Suggestion Page // GET: Suggestion/Delete/5 public ActionResult Delete(int?id) { if ((HttpContext.Session.GetString("Role") == null) || (HttpContext.Session.GetString("Role") != "Lecturer")) { return(RedirectToAction("Index", "Home")); } //if the query string is empty, return to the index if (id == null) { TempData["Message"] = "Please Select A Suggestion To Delete"; return(RedirectToAction("Index")); } //retrieve all the suggestion details Suggestion suggestion = suggestionContext.GetSuggestionDetails(id.Value); //check whether suggestion exists if (suggestion == null) { TempData["Message"] = "The Suggestion does not exist!"; return(RedirectToAction("Index")); } //check if it's NOT the lecturer's suggestion if (suggestion.LecturerId != Convert.ToInt32(HttpContext.Session.GetString("ID"))) { TempData["Message"] = "You are not allowed to delete other lecturer's suggestion!"; return(RedirectToAction("Index")); } //map the suggestion to proper fields SuggestionViewModel suggestionVM = MapToStudentVM(suggestion); return(View(suggestionVM)); }
// GET: Suggestions public ActionResult Index() { SuggestionViewModel model = new SuggestionViewModel(); model.Items = GetItems(); return(View(model)); }
public async Task <IActionResult> DosageSchemeMed([Bind(sugProperties)] SuggestionViewModel s, string personId, string button) { Suitability suitable; var medicineId = s.ID; var perObj = await persons.GetObject(personId); if (button != "prior") { bool suitableMed = await CheckMedicineSuitability(personId, medicineId); if (!suitableMed) { var messageContent = await FindConflict(personId, medicineId); ViewBag.Dictionary = messageContent; ModelState.AddModelError(string.Empty, ""); ViewBag.AfterError = true; await SetPropertiesPerson(medicineId); ViewBag.DefaultPerson = personId; } } if (!ModelState.IsValid) { return(View(s)); } var currentDate = DateTime.Now; DateTime?untilDate = null; if (s.Length != null && s.Length != "") { untilDate = currentDate.AddDays(double.Parse(s.Length)); } var dosageId = Guid.NewGuid().ToString(); var schemeId = Guid.NewGuid().ToString(); var medObj = await medicines.GetObject(medicineId); var dosage = DosageObjectFactory.Create(dosageId, s.TypeOfTreatment, personId, medicineId, currentDate, untilDate); var scheme = SchemeObjectFactory.Create(schemeId, dosageId, "1", s.Length, s.Amount, s.Times, s.TimeOfDay, currentDate, untilDate); var o = await personMedicines.GetObject(medicineId, personId); if (o.DbRecord.MedicineID == "Unspecified") { suitable = Suitability.Teadmata; } else { suitable = Suitability.Jah; await personMedicines.DeleteObject(o); } await personMedicines.AddObject(PersonMedicineObjectFactory.Create(perObj, medObj, suitable, currentDate)); await dosages.AddObject(dosage); await schemes.AddObject(scheme); return(RedirectToAction("PatientInfo", PersonViewModelFactory.Create(perObj))); }
/// <summary> /// Initializes a new instance of the <see cref="SuggestionPage" /> class. /// </summary> public SuggestionPage() { InitializeComponent(); var userService = App.Kernel.Get <IUserService>(); var viewModel = new SuggestionViewModel(userService, this); this.BindingContext = viewModel; }
public ActionResult SuggestProject() { DBDal dal = new DBDal(); SuggestionViewModel suggestionvm = new SuggestionViewModel(); suggestionvm.suggestion = new Suggestion(); return(View(suggestionvm)); }
public ActionResult Create(SuggestionViewModel suggestionViewModel) { if (ModelState.IsValid) { var suggestion = Mapper.Map <Suggestion>(suggestionViewModel); var userMail = User.Identity.Name; var employee = employeeService.GetAll(e => e.Email == userMail).FirstOrDefault().Id; suggestion.EmployeeId = employee; suggestionService.Insert(suggestion); return(RedirectToAction("Index")); } return(View(suggestionViewModel)); }
/// <summary> /// Transforms Suggestion into SuggestionViewModel /// </summary> public static SuggestionViewModel ToViewModel(this Suggestion input) { var result = new SuggestionViewModel { Id = input.Id, Title = input.Title, Url = input.Url, Responses = input.Responses != null?JsonConvert.DeserializeObject <ICollection <object> >(input.Responses) : null, ChildrenCount = input.Children?.Count }; return(result); }
public IActionResult Get(int id) { Suggestion _suggestion = _suggestionRepository .GetSingle(s => s.Id == id, s => s.Creator, s => s.Area); if (_suggestion == null) { return(NotFound()); } SuggestionViewModel _suggestionVM = Mapper.Map <Suggestion, SuggestionViewModel>(_suggestion); return(new OkObjectResult(_suggestionVM)); }
public SuggestionViewModel GetPlan(string ssn) { //List<string> ids = helper.GetDiagnosisIds(ssn); SuggestionViewModel model = new SuggestionViewModel(); /* High Blood Pressure * Lactose Intolerant * Pregnancy * */ return(model); }
private void OtherKeysList_MouseDoubleClick(object sender, MouseButtonEventArgs args) { if (args.ChangedButton == MouseButton.Left) { SuggestionViewModel suggestion = OtherKeysList.SelectedItem as SuggestionViewModel; if (suggestion != null) { TextKeyText.Text = suggestion.TextKey; AutoSelectKeyText(); TextKeyText.Focus(); // TODO: Also update the translated text from suggestion.BaseText? Consider different parameter names! } } }
private void OtherKeysList_KeyDown(object sender, KeyEventArgs args) { if (args.Key == Key.Enter && args.KeyboardDevice.Modifiers == 0) { // See OtherKeysList_MouseDoubleClick! SuggestionViewModel suggestion = OtherKeysList.SelectedItem as SuggestionViewModel; if (suggestion != null) { TextKeyText.Text = suggestion.TextKey; AutoSelectKeyText(); TextKeyText.Focus(); } args.Handled = true; } }
public ActionResult UpdateSuggestions(String currentWord) { //List<String> results = new List<String>(); //results.Add("cat"); //results.Add("dog"); //results.Add("fish"); List <String> results = Intelliscents.ShowMethods(currentWord); SuggestionViewModel vm = new SuggestionViewModel(); vm.Suggestions = results; vm.CurrentWord = currentWord; return(PartialView("_Suggestions", vm)); }
//Upon new PO creation - this is the main method public List <SuggestionViewModel> GetSuggestionList() { List <string> itemList = db.Catalogues.Select(x => x.itemId).ToList(); List <SuggestionViewModel> listSuggest = new List <SuggestionViewModel>(); //Iterate catalogue and retrieve items that fulfill re-order conditions foreach (string item in itemList) { SuggestionViewModel orderItem = AdviceOnOrderQty(item); if (orderItem != null) { listSuggest.Add(orderItem); } } return(listSuggest); }
/// <summary> /// Executes this command. /// </summary> /// <param name="model">The model.</param> /// <returns> /// A list of tags. /// </returns> public List <LookupKeyValue> Execute(SuggestionViewModel model) { var query = Repository.AsQueryable <Models.Tag>() .Where(tag => tag.Name.Contains(model.Query)); if (model.ExistingItemsArray.Length > 0) { query = query.Where(tag => !model.ExistingItems.Contains(tag.Name) && !model.ExistingItems.Contains(tag.Id.ToString().ToUpper())); } return(query.OrderBy(tag => tag.Name) .Select(tag => new LookupKeyValue { Key = tag.Id.ToString(), Value = tag.Name }) .ToList()); }
public ActionResult PrintSuggests() { if (User.Identity.Name.Split('|')[2].Equals("2")) { DBDal dal = new DBDal(); List <Suggestion> objSuggests = dal.Suggestions.ToList <Suggestion>(); SuggestionViewModel suggestionvm = new SuggestionViewModel(); suggestionvm.suggestion = new Suggestion(); suggestionvm.suggestions = objSuggests; return(View(suggestionvm)); } else { return(RedirectToRoute("DefaultPage")); } }
public ActionResult Edit(Suggestion suggestion) { //check whether description is null or 'empty' string if (suggestion.Description == null || suggestion.Description == " ") { ViewData["Message"] = "Description Field Cannot be Empty!"; SuggestionViewModel suggestionVM = MapToStudentVM(suggestion); return(View(suggestionVM)); } //if everything is ok, update the suggestion if (ModelState.IsValid) { suggestionContext.Update(suggestion); return(RedirectToAction("Index")); } return(View(suggestion)); }
public IActionResult Suggestion() { var suggestions = _omdbApiService.RequestMovieSuggestions().Concat(_omdbApiService.RequestTvSuggestions()); var suggestionsTopRated = _omdbApiService.RequestMovieSuggestionsTopRated().Concat(_omdbApiService.RequestTvSuggestionsTopRated()); var suggestionsTrending = _omdbApiService.RequestMovieSuggestionsTrending().Concat(_omdbApiService.RequestTvSuggestionsTrending()); var suggestionsUpcoming = _omdbApiService.RequestMovieSuggestionsUpcoming().Concat(_omdbApiService.RequestTvSuggestionsUpcoming()); var viewModel = new SuggestionViewModel() { SuggestionTorrents = suggestions, SuggestionTopRated = suggestionsTopRated, SuggestionTrending = suggestionsTrending, SuggestionUpcoming = suggestionsUpcoming }; return(View(viewModel)); }
// View All Suggestion Posted by the Currently Logged In Lecturer // GET: Suggestion public ActionResult Index() { if ((HttpContext.Session.GetString("Role") == null) || (HttpContext.Session.GetString("Role") != "Lecturer")) { return(RedirectToAction("Index", "Home")); } List <SuggestionViewModel> suggestionVMList = new List <SuggestionViewModel>(); List <Suggestion> suggestionList = suggestionContext.GetSuggestionPostedByMentor(Convert.ToInt32(HttpContext.Session.GetString("ID"))); foreach (Suggestion suggestion in suggestionList) { SuggestionViewModel suggestionVM = MapToStudentVM(suggestion); suggestionVMList.Add(suggestionVM); } return(View(suggestionVMList)); }
/// <summary> /// Executes this command. /// </summary> /// <param name="model">The model.</param> /// <returns> /// A list of roles. /// </returns> public List <LookupKeyValue> Execute(SuggestionViewModel model) { var allRoleNames = cacheService.Get(CacheKey, TimeSpan.FromSeconds(30), GetAllRoleNames); var query = allRoleNames .Where(role => role.ToLower().Contains(model.Query.ToLower())); if (model.ExistingItemsArray.Length > 0) { query = query.Where(role => !model.ExistingItems.Contains(role)); } return(query .Select(role => new LookupKeyValue { Key = role, Value = role }) .ToList()); }
/// <summary> /// Executes this command. /// </summary> /// <param name="model">The model.</param> /// <returns> /// A list of languages. /// </returns> public List <LookupKeyValue> Execute(SuggestionViewModel model) { var query = model.Query.ToLowerInvariant(); var alreadyAdded = Repository.AsQueryable <Models.Language>().Select(c => c.Code).ToList(); alreadyAdded.Add(System.Globalization.CultureInfo.InvariantCulture.Name); return(System.Globalization.CultureInfo .GetCultures(System.Globalization.CultureTypes.AllCultures) .Where(culture => culture.GetFullName().ToLowerInvariant().Contains(query)) .Where(cullture => !alreadyAdded.Contains(cullture.Name)) .OrderBy(culture => culture.Name) .Select(culture => new LookupKeyValue { Key = culture.Name, Value = culture.GetFullName() }) .ToList()); }
public ActionResult Edit(SuggestionViewModel suggestionViewModel) { if (ModelState.IsValid) { // Suggestion ı edit yaptıktan sonra FirstName ve LastName alanı boş geliyordu(employee null olarak update ediliyordu), onun için suggestion ı veren employee bulundu ve suggestionViewModel e update öncesi eklendi //suggestionViewModel'e EmployeeId eklenmezse FirstName LastName bulamıyor. var employeeId = suggestionService.GetAll(f => f.Id == suggestionViewModel.Id).FirstOrDefault().EmployeeId; //var employee = employeeService.GetAll(f => f.Id == employeeId).FirstOrDefault(); //var employee = employeeService.GetAll().FirstOrDefault(f => f.Suggestions.FirstOrDefault().Id == suggestionViewModel.Id); //var employeeViewModel = Mapper.Map<EmployeeViewModel>(employee); suggestionViewModel.EmployeeId = employeeId; //suggestionViewModel.Employee = employeeViewModel; var suggestion = Mapper.Map <Suggestion>(suggestionViewModel); suggestionService.Update(suggestion); return(RedirectToAction("Index")); } return(View(suggestionViewModel)); }
public ActionResult Index(string latitude, string longtitude, string emotion = "Neutral") { if (this.Session["SpotifyToken"] == null) { return(this.RedirectToAction("SpotifyLogin", "SpotifyAccount", new { returnUrl = $"/Suggestion?latitude={latitude}&longtitude={longtitude}&emotion={emotion}" })); } string weather = this.GetWeather(latitude, longtitude); var emotionSpotify = new List <string>(); var weatherSpotify = new List <string>(); try { emotionSpotify = this.GetSpotifySuggestions(emotion); weatherSpotify = this.GetSpotifySuggestions(weather); } catch (NullReferenceException) { return(this.RedirectToAction("SpotifyLogin", "SpotifyAccount", new { returnUrl = string.Format("/Suggestions/Index?latitude={0}&longtitude={1}&emotion={2}", latitude, longtitude, emotion) })); } var emotionYoutube = this.GetYouTubeSuggestions(emotion); var weatherYoutube = this.GetYouTubeSuggestions(weather); var model = new SuggestionViewModel() { Emotion = emotion, Weather = weather, SpotifyEmotionResults = emotionSpotify, SpotifyWeatherResults = weatherSpotify, YoutubeEmotionResults = emotionYoutube, YoutubeWeatherResults = weatherYoutube }; return(View(model)); }
public IActionResult Create([FromBody] SuggestionViewModel suggestion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Suggestion _newSuggestion = Mapper.Map <SuggestionViewModel, Suggestion>(suggestion); _newSuggestion.DateCreated = DateTime.Now; _newSuggestion.DateUpdated = _newSuggestion.DateCreated; _newSuggestion.Status = SuggestionStatus.Nuevo; _suggestionRepository.Add(_newSuggestion); _suggestionRepository.Commit(); suggestion = Mapper.Map <Suggestion, SuggestionViewModel>(_newSuggestion); CreatedAtRouteResult result = CreatedAtRoute("GetSuggestion", new { controller = "Suggestions", id = suggestion.Id }, suggestion); return(result); }
public SuggestionViewModel MapToStudentVM(Suggestion suggestion) { if (suggestion != null) { string studentName = ""; List <Student> studentList = studentContext.GetAllStudent(); foreach (Student student in studentList) { if (student.StudentID == suggestion.StudentId) { studentName = student.Name; break; } } string suggestionStatus; if (suggestion.Status == 'N') { suggestionStatus = "Not Acknowledged"; } else { suggestionStatus = "Acknowledged"; } SuggestionViewModel suggestionVM = new SuggestionViewModel { SuggestionId = suggestion.SuggestionId, LecturerId = suggestion.LecturerId, Description = suggestion.Description, Status = suggestionStatus, DateCreated = suggestion.DateCreated, StudentName = studentName }; return(suggestionVM); } else { return(null); } }
public ActionResult Send(int[] types) { int flag = 0; SuggestionViewModel suggestvm = new SuggestionViewModel(); Suggestion objSuggestion = new Suggestion(); objSuggestion.ID = Request.Form["suggestion.ID"].ToString(); objSuggestion.FirstName = Request.Form["suggestion.FirstName"].ToString(); objSuggestion.LastName = Request.Form["suggestion.LastName"].ToString(); objSuggestion.Description = Request.Form["suggestion.Description"].ToString(); objSuggestion.Location = Request.Form["suggestion.Location"].ToString(); objSuggestion.Area = Request.Form["suggestion.Area"].ToString(); objSuggestion.Phone = Request.Form["suggestion.Phone"].ToString(); objSuggestion.ProjectName = Request.Form["suggestion.ProjectName"].ToString(); if (types != null && types.Length == 1) { flag = types[0]; } else if (types != null && types.Length == 2) { flag = 3; } DBDal dal = new DBDal(); if (ModelState.IsValid && flag != 0) { objSuggestion.Type = flag; dal.Suggestions.Add(objSuggestion); dal.SaveChanges(); suggestvm.suggestion = new Suggestion(); } else { suggestvm.suggestion = objSuggestion; } return(View("SuggestProject", suggestvm)); }
public SuggestionViewModel AdviceOnSpecialRequest(SuggestionViewModel itemToOrder) { string itemNo = itemToOrder.ItemId; itemToOrder.SQuantity = itemToOrder.SQuantity + db.SpecialRequests.Where(x => x.itemId == itemNo && x.status == "Special").Select(x => x.requestQty).ToList().Sum(); List <SpecialRequest> specialRequest = db.SpecialRequests.Where(x => x.itemId == itemNo && x.status == "Special").ToList <SpecialRequest>(); if (specialRequest.Any()) { foreach (SpecialRequest x in specialRequest) { if (itemToOrder.remark == null) { itemToOrder.remark = "Special Qty : " + x.requestQty + " (Special Request ID : " + x.specialId + ")"; } else { itemToOrder.remark = itemToOrder.remark + " , Special Qty : " + x.requestQty + " (Special Request ID : " + x.specialId + ")"; } } } return(itemToOrder); }
public ActionResult Delete(Suggestion obj) { if (User.Identity.Name.Split('|')[2].Equals("2")) { DBDal dal = new DBDal(); if (obj != null) { List <Suggestion> suggest = (from u in dal.Suggestions where (u.ID == obj.ID) select u).ToList(); dal.Suggestions.Remove(suggest.First()); dal.SaveChanges(); } List <Suggestion> objSuggests = dal.Suggestions.ToList <Suggestion>(); SuggestionViewModel suggestionvm = new SuggestionViewModel(); suggestionvm.suggestions = objSuggests; return(View("PrintSuggests", suggestionvm)); } else { return(RedirectToRoute("DefaultPage")); } }
public ActionResult SuggestUsers(SuggestionViewModel model) { var suggestedRoles = GetCommand <SearchUsersCommand>().ExecuteCommand(model); return(Json(new { suggestions = suggestedRoles })); }