public ActionResult Create(int?theaterId) { var model = new MovieViewModel(); if (theaterId.HasValue) { model.Theater = TheaterManager.GetByTheaterId(theaterId.Value); } var allRatings = RatingManager.GetAll(); var allGenres = GenreManager.GetAll(); var checkBoxListItems = new List <CheckBoxListItem>(); model.Ratings = allRatings; foreach (var genre in allGenres) { checkBoxListItems.Add(new CheckBoxListItem() { ID = genre.GenreId, Display = genre.GenreName, IsChecked = false // On the add view, no genres will be selected by default }); } model.Genres = checkBoxListItems; ViewBag.AvailableTheaters = TheaterManager.GetAll(); return(View(model)); }
protected void btnUpdate_Click(object sender, EventArgs e) { try { // Get the one the user has selected int index = ddlRatings.SelectedIndex; rating = ratings[ddlRatings.SelectedIndex]; // Get the typed description from the screen rating.Description = txtDescription.Text; // Add to the database RatingManager.Update(rating); // Update to the list ratings[ddlRatings.SelectedIndex] = rating; Rebind(); ddlRatings.SelectedIndex = index; ddlRatings_SelectedIndexChanged(sender, e); } catch (Exception ex) { Response.Write("Error: " + ex.Message); } }
public ActionResult Details(int id) { var model = MovieManager.GetById(id); var ratingName = RatingManager.GetById(model.RatingId); model.RatingName = ratingName.RatingName; var movieGenres = GenreManager.GetForMovie(id); var checkBoxListItems = new List <CheckBoxListItem>(); foreach (var genre in movieGenres) { checkBoxListItems.Add(new CheckBoxListItem() { ID = genre.GenreId, Display = genre.GenreName, IsChecked = movieGenres.Any(x => x.GenreId == genre.GenreId) }); } model.Genres = checkBoxListItems; return(View(model)); }
internal static void Add(Rbr_Db pDb, CarrierAcctDto pCarrierAcct, int pBaseRouteId, out int pCarrierRouteId) { var _carrierRouteRow = new CarrierRouteRow(); _carrierRouteRow.Carrier_acct_id = pCarrierAcct.CarrierAcctId; _carrierRouteRow.Acd_target = pCarrierAcct.DefaultRoute.ACDTarget; _carrierRouteRow.Acd_time_window = pCarrierAcct.DefaultRoute.ACDTimeWindow; _carrierRouteRow.Asr_target = pCarrierAcct.DefaultRoute.ASRTarget; _carrierRouteRow.Asr_time_window = pCarrierAcct.DefaultRoute.ASRTimeWindow; _carrierRouteRow.Next_ep = pCarrierAcct.DefaultRoute.NextEP; if (pBaseRouteId > 0) { //Regular ServiceRoute _carrierRouteRow.Route_id = pBaseRouteId; _carrierRouteRow.RouteStatus = Status.Active; } else { //Default CarrierRoute, set CarrierRouteId = -CarrierAcctId, NO Base RouteId pCarrierAcct.DefaultRoute.RatedRouteId = -pCarrierAcct.CarrierAcctId; _carrierRouteRow.Carrier_route_id = pCarrierAcct.DefaultRoute.RatedRouteId; _carrierRouteRow.RouteStatus = Status.Blocked; //for Default ServiceRoute } pDb.CarrierRouteCollection.Insert(_carrierRouteRow); if (pCarrierAcct.IsRatingEnabled || pBaseRouteId == 0) { //always add Def RatingInfo for Def Route RatingManager.AddDefaultRatingInfo(pDb, _carrierRouteRow.Carrier_route_id, pCarrierAcct.DefaultRatingInfo, RouteType.Carrier); } pCarrierRouteId = _carrierRouteRow.Carrier_route_id; }
// GET: Movie/Edit/5 public ActionResult Edit(int id) { if (Authenticate.IsAuthenticated()) { ViewBag.Title = "Edit"; MovieGenresDirectorsRatingsFormats mgdrf = new MovieGenresDirectorsRatingsFormats(); mgdrf.Movie = MovieManager.LoadById(id); mgdrf.RatingList = RatingManager.Load(); mgdrf.FormatList = FormatManager.Load(); mgdrf.GenreList = GenreManager.Load(); mgdrf.DirectorList = DirectorManager.Load(); mgdrf.Movie.Genres = MovieManager.LoadGenres(id); mgdrf.GenreIds = mgdrf.Movie.Genres.Select(g => g.Id); Session["genreids"] = mgdrf.GenreIds; return(View(mgdrf)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
public IEnumerator ShareScreenshot() { yield return(new WaitForSeconds(1)); // wait for graphics to render yield return(new WaitForEndOfFrame()); // prepare texture with Screen and save it Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, true); texture.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height), 0, 0); texture.Apply(); Sprite screenshot = Sprite.Create(texture, new Rect(0f, 0f, Screen.width, Screen.height), new Vector2(0, 0)); ScreenBackground.GetComponent <Image>().sprite = screenshot; ScreenBackgroundParent.SetActive(true); // save to persistentDataPath File byte[] data = texture.EncodeToPNG(); destination = Path.Combine(Application.persistentDataPath, System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png"); File.WriteAllBytes(destination, data); RatingManager ratingManager = FindObjectOfType <RatingManager>(); if (ratingManager != null) { ratingManager.die(); } }
public static Result SaveRatingHistoryEntries(IRatingHistoryEntry pRatingHistoryEntry, int[] pRatedRouteIds) { var _result = new Result(true, null); try { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pRatingHistoryEntry, pRatedRouteIds)) { foreach (int _routeId in pRatedRouteIds) { var _ratingHistoryEntry = (IRatingHistoryEntry)Cloner.Clone(pRatingHistoryEntry); if (_routeId != pRatingHistoryEntry.RatedRouteId) //NOTE: not a leading route, set RouteId=one of the selected, and set RateInfoId=0 { _ratingHistoryEntry.RatedRouteId = _routeId; _ratingHistoryEntry.RateInfoId = 0; } RatingManager.SaveRatingHistoryEntry(_db, _ratingHistoryEntry); if (_routeId == pRatingHistoryEntry.RatedRouteId) //NOTE: this is the leading route, update sent ref on it { pRatingHistoryEntry = _ratingHistoryEntry; } } _tx.Commit(); } } } catch (Exception _ex) { TimokLogger.Instance.LogRbr(LogSeverity.Error, "RateController.Save(2)", string.Format("Exception:\r\n{0}", _ex)); _result = new Result(false, _ex.Message); } return(_result); }
// GET: Movie/Edit/5 public ActionResult Edit(int id) { if (Authenticate.IsAuthenticated()) { ViewBag.Title = "Edit"; MovieGenresDirectorsRatingsFormats mgdrf = new MovieGenresDirectorsRatingsFormats(); mgdrf.Movie = MovieManager.LoadByID(id); mgdrf.Directors = DirectorManager.Load(); mgdrf.Genres = GenreManager.Load(); mgdrf.Ratings = RatingManager.Load(); mgdrf.Formats = FormatManager.Load(); IEnumerable <int> existingGenreIds = new List <int>(); mgdrf.Movie.Genres = MovieManager.LoadGenres(id); mgdrf.GenreIds = mgdrf.Movie.Genres.Select(a => a.Id); //put genres in session Session["genreids"] = mgdrf.GenreIds; return(View(mgdrf)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
public ActionResult Edit(int id) { Movie movie = new Movie(); using (manager = new MovieManager()) { movie = manager.GetById(id); } if (movie == null) { return(HttpNotFound()); } else { MovieViewModel vm = new MovieViewModel(); using (GenreManager genreManager = new GenreManager()) { vm.PossibleGenres = genreManager.GetAll(); } using (RatingManager ratingManager = new RatingManager()) { vm.PossibleRatings = ratingManager.GetAll(); } using (DirectorManager directorManager = new DirectorManager()) { vm.PossibleDirectors = directorManager.GetAll(); } using (FormatManager formatManager = new FormatManager()) { vm.PossibleFormats = formatManager.GetAll(); } //vm.MovieId = movie.Id; vm.Movie = movie; vm.MovieDescription = movie.Description; vm.MovieCost = movie.Cost; vm.MovieTitle = movie.Title; vm.ImagePath = movie.ImagePath; vm.CurrentGenres = new List <int>(); foreach (var a in movie.Genres) { vm.CurrentGenres.Add(a.Id); } return(View(vm)); } }
// GET: Movie/Edit/5 public ActionResult Edit(int id) { if (Authenticate.IsAuthenticated()) { MovieGenresDirectorsRatingsFormats mgdrf = new MovieGenresDirectorsRatingsFormats(); mgdrf.Movie = MovieManager.LoadById(id); mgdrf.DirectorList = DirectorManager.Load(); mgdrf.RatingList = RatingManager.Load(); mgdrf.FormatList = FormatManager.Load(); mgdrf.Genres = GenreManager.Load(); // Load them all // Deal with the selected ones mgdrf.Movie.Genres = MovieManager.LoadGenres(id); mgdrf.GenreIds = mgdrf.Movie.Genres.Select(a => a.Id); // Select the ids // Put them into session Session["genreids"] = mgdrf.GenreIds; return(View(mgdrf)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { //get the selected degreetype object that i want to use item = items[ddlExisting.SelectedIndex]; //update degreeType Description item.Description = txtDescription.Text; //delete it from the database int results = RatingManager.Update(item); //update the list with new description items[ddlExisting.SelectedIndex] = item; //rebind Rebind(); Response.Write("Updated " + results + " rows..."); } catch (Exception ex) { Response.Write(ex.Message); } }
/// <summary> /// Method to rate an instance by id /// </summary> /// <returns> /// Returns bad request in case of token not given as header/improper token or if user with the given token has already rated the instance /// Returns the modified entity in case the rate was successful /// </returns> public IHttpActionResult PostUserRating(int newsInstanceId, int rating) { IEnumerable <string> values; if (!Request.Headers.TryGetValues("Token", out values)) { return(BadRequest("Token was not given. Issue a token via api/User/Token and attach it to as a header to your request")); } string token = values.FirstOrDefault(); LoggingError loggingError; RatingManager.TryLogRating(db, token, newsInstanceId, rating, out loggingError); switch (loggingError) { case LoggingError.UnregistredToken: return(BadRequest($"Token {token} is not registred!")); case LoggingError.NoNewsRated: return(BadRequest("User with this token has already rated that piece of news")); case LoggingError.RatingOutOfBounds: return(BadRequest("Given rating was out of bounds. The range of rating is from 1 to 5")); case LoggingError.NoError: NewsInstance newsInstance = RatingManager.RateNews(db, newsInstanceId, rating); if (newsInstance == null) { return(NotFound()); } return(Ok((NewsInstanceViewModel)newsInstance)); default: return(BadRequest()); } }
public void InsertTest() { Rating rating = new Rating(); rating.Description = "Bananas"; Assert.IsTrue(RatingManager.Insert(rating) > 0); }
internal static void Add(Rbr_Db pDb, short pServiceId, int pBaseRouteId, out int pRouteId) { pRouteId = 0; if (pBaseRouteId == 0) { throw new ArgumentException("BaseRouteId cannot be 0.", "pBaseRouteId"); } var _service = ServiceManager.GetService(pDb, pServiceId); var _wholesaleRouteRow = new WholesaleRouteRow(); _wholesaleRouteRow.Service_id = _service.ServiceId; _wholesaleRouteRow.Route_id = pBaseRouteId; _wholesaleRouteRow.RouteStatus = Status.Active; pDb.WholesaleRouteCollection.Insert(_wholesaleRouteRow); if (_service.IsRatingEnabled) { RatingManager.AddDefaultRatingInfo(pDb, _wholesaleRouteRow.Wholesale_route_id, _service.DefaultRatingInfo, RouteType.Wholesale); } pRouteId = _wholesaleRouteRow.Wholesale_route_id; }
public void UpdateTest() { Rating rating = RatingManager.LoadByID(1); rating.Description = "Oo"; Assert.IsTrue(RatingManager.Update(rating) > 0); }
public void UpdateTest() { Rating rating = RatingManager.LoadById(5); rating.Description = "updated description"; Assert.IsTrue(RatingManager.Update(rating) > 0); }
public IActionResult Add(RatingModel model) { if (ModelState.IsValid) { using (var db = new DB()) { var student = StudentManager.GetAll().FirstOrDefault(c => c.Name == model.StudentName && c.Surname == model.StudentSurname); var course = CourseManager.GetAll().FirstOrDefault(c => c.Course == model.CourseName); if (student != null && course != null) { RatingManager.Add(model.StudentName, model.StudentSurname, model.CourseName, model.Rating, model.Description); return(RedirectToAction(nameof(Index))); } else if (student == null) { ModelState.AddModelError("student", "Student not found!"); } else if (course == null) { ModelState.AddModelError("course", "Course not found!"); } } } return(View(model)); }
public IActionResult List(string name, string surname, string course) { var model = RatingManager.GetAll().Select(i => i.ToModel()).ToList(); model = model.Where(i => i.Student.Name == name && i.Student.Surname == surname || i.Course.Course == course).ToList(); return(View(model)); }
public ParentMeetingController(MeetingsManager meetingsManager, ParentAuthorizationManager parentAuthorizationManager, IMapper mapper, RatingManager ratingManager) { _meetingsManager = meetingsManager; _parentAuthorizationManager = parentAuthorizationManager; _mapper = mapper; _ratingManager = ratingManager; }
public void InsertTest() { Rating rating = new Rating { Description = "new description" }; Assert.AreNotEqual(0, RatingManager.Insert(rating)); }
public StudentMeetingsController(MeetingsManager meetingsManager, IMapper mapper, TutorsManager tutorsManager, RatingManager ratingManager) { _meetingsManager = meetingsManager; _mapper = mapper; _tutorsManager = tutorsManager; _ratingManager = ratingManager; }
public static Result UpdateRatingHistoryEntry(IRatingHistoryEntry pRatingHistoryEntry, RouteType pRouteType) { Result _result = new Result(true, null); try { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pRatingHistoryEntry)) { RatingHistoryEntry[] _ratingHistoryEntries = RatingManager.GetRatingHistoryEntries(_db, pRatingHistoryEntry.RatedRouteId, pRouteType); if (_ratingHistoryEntries == null || _ratingHistoryEntries.Length == 0) { return(new Result(false, "Error saving Rates, no RatingHistoryEntries found.")); } RatingHistoryEntry _ratingHistoryEntry = null; foreach (RatingHistoryEntry _rate in _ratingHistoryEntries) { if (_rate.RateInfoId == pRatingHistoryEntry.RateInfoId) { _ratingHistoryEntry = _rate; break; } } if (_ratingHistoryEntry == null) { return(new Result(false, "Error saving Rates, matching RatingHistoryEntry not found.")); } if (pRatingHistoryEntry.RatingInfo.RegularDayRateEntry != null) { _ratingHistoryEntry.RatingInfo.RegularDayRateEntry = pRatingHistoryEntry.RatingInfo.RegularDayRateEntry; _ratingHistoryEntry.FirstDate = pRatingHistoryEntry.FirstDate; _ratingHistoryEntry.LastDate = pRatingHistoryEntry.LastDate; } if (pRatingHistoryEntry.RatingInfo.WeekendRateEntry != null) { _ratingHistoryEntry.RatingInfo.WeekendRateEntry = pRatingHistoryEntry.RatingInfo.WeekendRateEntry; _ratingHistoryEntry.FirstDate = pRatingHistoryEntry.FirstDate; _ratingHistoryEntry.LastDate = pRatingHistoryEntry.LastDate; } if (pRatingHistoryEntry.RatingInfo.HolidayRateEntry != null) { _ratingHistoryEntry.RatingInfo.HolidayRateEntry = pRatingHistoryEntry.RatingInfo.HolidayRateEntry; _ratingHistoryEntry.FirstDate = pRatingHistoryEntry.FirstDate; _ratingHistoryEntry.LastDate = pRatingHistoryEntry.LastDate; } _ratingHistoryEntry.RateInfoId = 0; RatingManager.SaveRatingHistoryEntry(_db, _ratingHistoryEntry); _tx.Commit(); } } } catch (Exception _ex) { TimokLogger.Instance.LogRbr(LogSeverity.Error, "RateController.Save(1)", string.Format("Exception:\r\n{0}", _ex)); _result = new Result(false, _ex.Message); } return(_result); }
protected void Page_Load(object sender, EventArgs e) { RatingManager ratingManager = new RatingManager(); RatingDropDownList.DataValueField = "Id"; RatingDropDownList.DataTextField = "Description"; RatingDropDownList.DataSource = ratingManager.GetAll(); RatingDropDownList.DataBind(); }
public void LoadTest() { List <Rating> ratings = new List <Rating>(); ratings = RatingManager.Load(); int expected = 5; Assert.AreEqual(expected, ratings.Count); }
public ActionResult Questions() { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { List <Question> questions = RatingManager.GetAllQuestions(); return(View(questions)); } return(RedirectToAction("Index", "Home")); }
public RatingPublicAppService( IRatingRepository ratingRepository, ICmsUserLookupService cmsUserLookupService, RatingManager ratingManager) { RatingRepository = ratingRepository; CmsUserLookupService = cmsUserLookupService; RatingManager = ratingManager; }
public ActionResult EditQuestion(int id) { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { Question question = RatingManager.GetQuestionById(id); return(View(question)); } return(RedirectToAction("Index", "Home")); }
public ActionResult EditQuestion(Question question) { if (User.Identity.IsAuthenticated && User.IsInRole("Admin")) { RatingManager.EditQuestion(question); return(RedirectToAction("Questions", "Admin")); } return(RedirectToAction("Index", "Home")); }
public void OnDie() { //Do whatever you want here RatingManager ratingManager = FindObjectOfType <RatingManager>(); if (ratingManager != null) { ratingManager.die(); } }
public void GetAll_AllRatingsReturned_ExpectedCountEqualAcual() { using (RatingManager ratingManger = new RatingManager(new BrothershipUnitOfWork(DataContextCreator.CreateTestContext()))) { const int expectedCount = 5; int actualCount = ratingManger.GetAll().Count; Assert.AreEqual(expectedCount, actualCount); } }