public ViewResult Checkout(Order order, CustomerDetails shippingDetails) { if (order.OrderedTickets.Count() == 0) { ModelState.AddModelError("", "Sorry, you ordered nothing!"); } if (ModelState.IsValid) { foreach (var ticket in order.OrderedTickets) { Seat booked_seat = db.Seats.Find(s => s.Id == ticket.Seat); Seance seance_to_order = db.Seances.Find(s => s.Id == booked_seat.SeanceId); Row row = db.Rows.GetById(ticket.Row); booked_seat.IsBooked = true; seance_to_order.SeatsLeft--; db.Seances.Edit(seance_to_order, seance_to_order.Id); db.Seats.Edit(booked_seat, booked_seat.Id); Cinema cinema = db.Cinemas.Find(c => c.Id == seance_to_order.Hall.CinemaId); ticket.Seat = booked_seat.Number; ticket.Row = row.Number; ticket.Hall = seance_to_order.Hall.Name; ticket.Movie = seance_to_order.Movie.Name; ticket.Cinema = cinema.Name; } shippingDetails.SavePath = String.Format(AppDomain.CurrentDomain.BaseDirectory + "Store/"); processor.ProcessOrder(order, shippingDetails); order.Clear(); return(View("Completed")); } else { return(View(shippingDetails)); } }
public async Task <ActionResult <Seance> > PostSeance(Seance seance) { _context.Seances.Add(seance); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSeance", new { id = seance.SeanceId }, seance)); }
public ActionResult Create([Bind(Include = "SeanceId,DateSeance,AgentId,Photographe,Client,ForfaitId,Commentaire,Statut,ProprieteId")] Seance seance) { if (ModelState.IsValid) { Agent ag = unitOfWork.AgentRepository.ObtenirAgentParID(seance.AgentId); Forfait forf = unitOfWork.ForfaitRepository.GetByID(seance.ForfaitId); seance.Agent = ag; seance.Propriete = unitOfWork.ProprieteRepository.ObtenirProprieteParID(seance.ProprieteId); seance.Forfait = forf; unitOfWork.SeanceRepository.InsertSeance(seance); unitOfWork.Save(); return(RedirectToAction("Index")); } SelectList AgentId = new SelectList(unitOfWork.AgentRepository.ObtenirAgent(), "AgentId", "Nom", seance.AgentId); ViewBag.AgentId = AgentId; SelectList ProprieteId = new SelectList(unitOfWork.ProprieteRepository.ObtenirPropriete(), "ProprieteId", "Adresse", seance.ProprieteId); ViewBag.ProprieteId = ProprieteId; SelectList ForfaitId = new SelectList(unitOfWork.ForfaitRepository.ObtenirForfait(), "ForfaitId", "Nom", seance.ForfaitId); ViewBag.ForfaitId = ForfaitId; return(View(seance)); }
public int CreateSeance(SeanceInfo seance) { Seance newSeance = new Seance { MovieId = seance.MovieId, HallId = seance.HallId, ShowDate = seance.ShowDate, ShowTime = seance.ShowTime }; foreach (SeanceSeatView seanceSeat in seance.SessionSeats) { var newSeanceSeat = new SeanceSeat { SeanceId = newSeance.Id, SeatId = seanceSeat.SeatId, Price = seanceSeat.Price, IsBooked = seanceSeat.IsBooked }; _db.SeanceSeats.Add(newSeanceSeat); } _db.Seances.Add(newSeance); _db.SaveChanges(); return(newSeance.Id); }
public void SeanceTest() { Seance seance = new Seance(EventTests.GetSimpleEvent(), 1, new DateTime(2000, 10, 10), new DateTime(2000, 10, 11)); Assert.ThrowsException <ArgumentNullException>(() => { seance.Meetings = null; }, "Meetings cannot be null"); Assert.ThrowsException <ArgumentNullException>(() => { seance.UserPauses = null; }, "UserPauses cannot be null"); }
public async Task <IActionResult> Edit(int id, [Bind("Id_Seance,Day_Of_The_Week,Start_Time,End_Time,Fk_Matiere,Fk_Professeur,Fk_Groupe")] Seance seance) { if (id != seance.Id_Seance) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(seance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeanceExists(seance.Id_Seance)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Fk_Groupe"] = new SelectList(_context.Groupe, "Id_groupe", "Id_groupe", seance.Fk_Groupe); ViewData["Fk_Matiere"] = new SelectList(_context.Matiere, "Id_Matiere", "Id_Matiere", seance.Fk_Matiere); ViewData["Fk_Professeur"] = new SelectList(_context.Professeur, "Id_Utilisateur", "Id_Utilisateur", seance.Fk_Professeur); return(View(seance)); }
private void Coachs_Load(object sender, EventArgs e) { // bind data source to db using (ClubDbContext context = new ClubDbContext()) { coachBindingSource.DataSource = context.Coaches.ToList(); seanceBindingSource.DataSource = context.Seances.ToList(); if (activities.Count == 0) { var activityNamesInDb = context.Activites.ToList(); activities.Add("Choisir Votre Discipline"); foreach (var activity in activityNamesInDb) { activities.Add(activity.Nom); } // bind data to the cb collection of values activitiesCB.DataSource = activities; } currentCoach = coachBindingSource.Current as Coach; currentSeance = seanceBindingSource.Current as Seance; } // disable form for input security control formEnabled(false); // disable affecter dicipline label AffecterDicipline.Enabled = false; AffecterDicipline.ForeColor = Color.White; }
public async Task <IActionResult> Edit(int id, [Bind("Seance_id,Seance_Jour,Seance_Heure,Enseignant_id_FK,Matiere_id_FK,Salle_id_FK,Groupe_id_FK")] Seance seance) { if (id != seance.Seance_id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(seance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeanceExists(seance.Seance_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Enseignant_id_FK"] = new SelectList(_context.Enseignant, "Id", "Id", seance.Enseignant_id_FK); ViewData["Groupe_id_FK"] = new SelectList(_context.Groupes, "Groupe_id", "Groupe_id", seance.Groupe_id_FK); ViewData["Matiere_id_FK"] = new SelectList(_context.Matiere, "Matiere_id", "Matiere_id", seance.Matiere_id_FK); ViewData["Salle_id_FK"] = new SelectList(_context.Salle, "Salle_id", "Salle_id", seance.Salle_id_FK); return(View(seance)); }
private void UpdateOperation() { int id = -1; while (id < 0) { id = view.EnterId(); } if (id < 0) { throw new Exception("Wrong id"); } switch (view.entity) { case Entity.Movie: Movie m = view.MovieAddOrUpdateEnter(); m.Id = id; movieDAO.Update(m); break; case Entity.Seance: Seance s = view.SeanceAddOrUpdateEnter(movieDAO.GetList(), hallDAO.GetHalls()); s.Id = id; seanceDAO.Update(s); break; case Entity.Ticket: Ticket ticket = view.TicketAddOrUpdateGetSeance(seanceDAO.GetList()); ticket.Id = id; ticket = view.TicketAddOrUpdateGetSeat(hallDAO.GetSeatsInHall(ticket.Seance.HallId), ticket); ticketDAO.Update(ticket); break; } }
public IHttpActionResult PutSeance(int id, Seance seance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != seance.SeanceId) { return(BadRequest()); } db.Entry(seance).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SeanceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Seance = await _context.Seance .Include(s => s.LUE) .Include(s => s.LaSalle) .ThenInclude(s => s.LeBatiment) .Include(s => s.LeGroupe) .Include(s => s.Type).FirstOrDefaultAsync(m => m.ID == id); if (Seance == null) { return(NotFound()); } ViewData["UEID"] = new SelectList(_context.UE, "ID", "Intitule"); ViewData["SalleID"] = new SelectList(_context.Salle, "ID", "toString"); //ViewData["GroupeID"] = new SelectList(_context.Groupe, "ID", "toString"); ViewData["TypeID"] = new SelectList(_context.TypeSeance, "ID", "Intitule"); var Groupes = _context.Groupe.ToList(); //Je récupère les groupes pour avoir leur UE avec Groupe nullGrp = new Groupe(); //Je créer un groupe Tout le Monde nullGrp.ID = -1; nullGrp.NomGroupe = "Tout le Monde"; listGroupes.Add(nullGrp); foreach (Groupe grp in Groupes) //Je remplis ma liste avec mes groupes { listGroupes.Add(grp); } return(Page()); }
public ActionResult Edit([Bind(Include = "Seance_ID,Agent_ID,Photographe_ID,Adresse,DateSeance,Ville,Statut,DateFinSeance")] Seance seance) { bool dateBonne = true; try { DateTime date = DateTime.Parse(seance.DateSeance.ToString()); if (date < DateTime.Now) { dateBonne = false; } } catch (Exception e) { ViewBag.MessageError = "La date entrée n'est pas d'un format valide"; dateBonne = false; } if (ModelState.IsValid && dateBonne) { unitOfWork.SeanceRepository.Update(seance); unitOfWork.Save(); return(RedirectToAction("Index")); } ViewBag.Photographe_ID = new SelectList(unitOfWork.PhotographeRepository.Get(), "Photographe_ID", "Prenom", seance.Photographe_ID); return(View(seance)); }
public ActionResult Create([Bind(Include = "Seance_ID,Photographe_ID,Agent_ID,Adresse,DateSeance,Ville,Statut")] Seance seance) { seance.Photographe_ID = null; seance.Statut = "demandée"; var errors = ModelState.Values.SelectMany(v => v.Errors); if (ModelState.IsValid && seance.DateSeance >= DateTime.Now) { Disponibilite dispo = unitOfWork.DisponibiliteRepository.Get(filter: x => x.DateDebutDisponibilite == seance.DateSeance).FirstOrDefault(); seance.Photographe_ID = dispo.Photographe_ID; unitOfWork.SeanceRepository.Insert(seance); unitOfWork.Save(); return(RedirectToAction("IndexSeancesAgent", new { agentID = seance.Agent_ID })); } else { if (seance.DateSeance > seance.DateFinSeance) { ViewBag.MessageError = "La date choisie n'est pas valide. (La date de fin est plus tôt que la date de réservation)"; } else { ViewBag.MessageError = "La date choisie n'est pas valide. (Une date plus tard que maintenant)"; } } ViewBag.Agent_ID = new SelectList(unitOfWork.AgentRepository.Get(), "Agent_ID", "Nom", seance.Agent_ID); ViewBag.Disponibilites = new SelectList(unitOfWork.DisponibiliteRepository.Get().OrderBy(x => x.DateDebutDisponibilite).Where(x => x.DateDebutDisponibilite >= DateTime.Now), "DateDebutDisponibilite", "DateDebutDisponibilite"); return(View()); }
public void DeleteSeance(Seance seance) { //TODO : test existance Agent / candidate // date's seance not in the past context.Seance.Delete(seance); context.Save(); }
public ActionResult <ApiResponse <Seance> > AddSeance(Seance seance) { string returnError = null; var validations = new List <string>(); var seanceDuration = (seance.EndDate.Ticks - seance.StartDate.Ticks) / 600000000; if (seanceDuration > Convert.ToInt32(seance.Movie.DurationTime)) { seance.Places = new List <Place>(250); for (int i = 0; i < 250; i++) { seance.Places.Add(new Place { IsFree = true, IsSelected = false, Number = i + 1 } as Place); } returnError = (_repository.AddSeance(seance)); if (returnError != null) { validations.Add(returnError); } } else { validations.Add("To short seance."); } ApiResponse <Seance> response = new ApiResponse <Seance> { Data = seance, Token = _token.Generate(), validationMessages = validations }; return(Ok(response)); }
public async Task <IActionResult> MdfSea(int id, [Bind("Id_Seance,Id_Filiere,Id_Salle,Heure_D,Heure_F,Id_Matiere")] Seance seance) { if (id != seance.Id_Seance) { return(NotFound()); } if (ModelState.IsValid) { try { _db.Update(seance); await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeanceExists(seance.Id_Seance)) { return(NotFound()); } else { throw; } } return(RedirectToAction("IndexSea")); } ViewData["Nom_Filiere"] = new SelectList(_db.filieres, "Id_Filiere", "Nom_Filiere", seance.Id_Filiere); ViewData["Nom_Matiere"] = new SelectList(_db.matieres, "Id_Matiere", "Nom_Matiere", seance.Id_Matiere); ViewData["Nom_Salle"] = new SelectList(_db.salles, "Id_Salle", "Nom_Salle", seance.Id_Salle); return(View(seance)); }
public ApiResponseModel <Seance> Add([FromBody] AddRequestModel requestModel) { var responseModel = new ApiResponseModel <Seance>(); try { var record = new Seance(); record.Name = requestModel.Name; record.Date = requestModel.Date; record.Time = requestModel.Time; record.IsDeleted = false; var dbResult = _seanceService.Add(record); if (dbResult > 0) { responseModel.Data = record; // oluşturulan entity bilgisinde id kolonu atanmış olur ve entity geri gönderiliyor responseModel.ResultStatusCode = ResultStatusCodeStatic.Success; responseModel.ResultStatusMessage = "Success"; } else { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = "Could Not Be Saved"; } } catch (Exception ex) { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = ex.Message; } return(responseModel); }
static void Main(string[] args) { string js = "{\"Name\":\"sdfsd\",\"Start\":\"2018-10-08 23:30\"}"; js = js.Replace("{\"", "").Replace("\"}", ""); string[] filter = { "\",\"", "\":\"" }; string[] words = js.Split(filter, StringSplitOptions.None); Dictionary <string, string> list = new Dictionary <string, string>(); for (int i = 0; i < words.Length / 2; i++) { list.Add(words[i * 2], words[i * 2 + 1]); } Seance seance = new Seance(); seance.Name = list["Name"]; seance.Start = DateTime.ParseExact(list["Start"].Replace(" ", ""), "yyyy-MM-ddHH:mm", System.Globalization.CultureInfo.InvariantCulture); Console.WriteLine("Hello World!"); }
private void UpdateOperation() { long id = -1; while (id < 0) { id = view.EnterId(); } if (id < 0) { throw new Exception("Wrong id"); } switch (view.entity) { case Entity.Movie: Movie m = view.MovieAddOrUpdateEnter(); m.Id = id; movieDAO.Update(m); break; case Entity.Seance: Seance s = view.SeanceAddOrUpdateEnter(movieDAO.GetList(), hallDAO.GetHalls()); s.Id = id; seanceDAO.Update(s); break; /*case Entity.Booking: * Booking booking = view.BookingAddOrUpdate(); * booking.Id = id; * bookingDAO.Update(booking); * break;*/ } }
// Mettre à jour les contenus d'une séance - le contenu principal et l'ordre d'affichage. public void UpdateSeanceContents(SeanceViewModel seanceVM) { Seance seance = repository.GetSeance(seanceVM.SeanceID); // Mettre à jour les contenus seulement s'il y'en a. if (seance.SeanceContenus.Count > 0 || seance.SeancePromoes.Count > 0) { List <string> order = new List <string>(seanceVM.Order.Split(',')); // Traiter les contenu standard et court. foreach (var content in seance.SeanceContenus) { content.indexOrdre = order.IndexOf(content.ContenuTitre); if (content.ContenuTitre == seanceVM.PrincipalFilm) { content.estPrincipal = true; } else { content.estPrincipal = false; } } // Traiter les promos. foreach (var content in seance.SeancePromoes) { content.indexOrdre = order.IndexOf(content.PromoTitre); } } }
public void EditSeance(int seanceId, SeanceInfo seance) { Seance editSeance = _db.Seances.Find(seanceId); editSeance.ShowDate = seance.ShowDate; editSeance.ShowTime = seance.ShowTime; editSeance.MovieId = seance.MovieId; editSeance.HallId = seance.HallId; editSeance.ShowTime = seance.ShowTime; var seanceSeat = _db.SeanceSeats .Where(s => s.SeanceId == editSeance.Id); foreach (SeanceSeat editSeanceSeat in seanceSeat) { var foundSeanceSeat = seance.SessionSeats .Where(s => s.SeatId == editSeanceSeat.SeatId) .SingleOrDefault(); if (foundSeanceSeat != null) { editSeanceSeat.Price = foundSeanceSeat.Price; editSeanceSeat.IsBooked = foundSeanceSeat.IsBooked; } } _db.SaveChanges(); }
public BookingServiceTests() { this.seatsCount = 100; this.seance = new SeanceBuilder() .WithGuid(Guid.NewGuid()) .WithTime(new DateTime(2018, 03, 10, 12, 00, 00)) .WithFilm(fb => fb .WithGuid(Guid.NewGuid()) .WithTitle("Pan Tadeusz") .WithDescription("Fascinating novel") .WithDuration(120)) .WithRoom(rb => rb .WithGuid(Guid.NewGuid()) .WithNumber(1) .WithSeatsCount(seatsCount)) .WithBooking(bb => bb .WithGuid(Guid.NewGuid()) .WithBoughtBool(true) .WithPlaces("1:2:3:4")) .WithBooking(bb => bb .WithGuid(Guid.NewGuid()) .WithBoughtBool(true) .WithPlaces("5:6:7")) .Build(); var contextBuilder = new MockedDbContextBuilder(); var mockedContext = contextBuilder .WithSeance(seance) .Build(); this.bookingService = new BookingService(mockedContext); }
public async Task <IActionResult> Edit(int id, [Bind("ID,ID_CinemaHall,ID_Movie,Date,StartingTime,ID_Cinema")] Seance seance) { if (id != seance.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(seance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeanceExists(seance.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(seance)); }
public ServiceResult SeansEkle(SeanceDTO dto) { DateTime cd = DateTime.Now; Seance seance = new Seance() { FinishTime = dto.FinishTime, StartTime = dto.StartTime, IsActive = true, IsDeleted = false, CreatedDate = cd.Date, UserId = SessionHelper.CurrentUser.Id, Id = Guid.NewGuid() }; ServiceResult result; try { Seance islemYapildiMi = _uow.GetRepository <Seance>().Add(seance); if (islemYapildiMi != null) { result = new ServiceResult("İşlem başarılı", ResultState.Success); } else { result = new ServiceResult("Yapılacak bir işlem kaydına rastlanmadı.", ResultState.Warning); } } catch (Exception ex) { result = new ServiceResult("Hata", ResultState.Error); } return(result); }
public async Task <IActionResult> PutSeance(int id, Seance seance) { if (id != seance.SeanceId) { return(BadRequest()); } _context.Entry(seance).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeanceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ServiceResult SeansSil(SeanceDTO dto) { var seance = _uow.GetRepository <Seance>().Get(dto.Id); seance.IsDeleted = true; seance.UserId = SessionHelper.CurrentUser.Id; ServiceResult result; try { Seance islemYapildiMi = _uow.GetRepository <Seance>().Update(seance); if (islemYapildiMi != null) { result = new ServiceResult("İşlem Başarılıdır.", ResultState.Success); } else { result = new ServiceResult("Yapılacak bir işlem kaydına rastlanamadı", ResultState.Warning); } } catch (Exception ex) { result = new ServiceResult("Hata", ResultState.Error); } return(result); }
public ActionResult Sommaire(int id) { var cheminBase = AppDomain.CurrentDomain.BaseDirectory + @"Images\Photos\"; //définir les droits d’accès DirectorySecurity securityRules = new DirectorySecurity(); securityRules.AddAccessRule(new FileSystemAccessRule(ConfigurationManager.AppSettings["WillUserName"], FileSystemRights.FullControl, AccessControlType.Allow)); Seance seance = unitOfWork.SeanceRepository.ObtenirSeanceComplete(id); //string directory = "\\images\\photos\\"; string directory = cheminBase; ICollection <Photo> lstPhoto = seance.Propriete.Photos; //string path = cheminBase + seance.ProprieteId + "\\" + "SeanceDu" + seance.DateSeance.Value.ToString("yyyy-MM-dd HH-mm-ss") + ".zip"; string path = Path.Combine(cheminBase, seance.ProprieteId.ToString()); string fileName = cheminBase + "SeanceDu" + seance.DateSeance.Value.ToString("yyyy-MM-dd HH-mm-ss") + ".zip"; string fileNameDownload = "SeanceDu" + seance.DateSeance.Value.ToString("yyyy-MM-dd HH-mm-ss") + ".zip"; ZipFile zip = new ZipFile(); zip.AddDirectory(path); zip.Save(cheminBase + "SeanceDu" + seance.DateSeance.Value.ToString("yyyy-MM-dd HH-mm-ss") + ".zip"); //download Response.ContentType = "application/zip"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileNameDownload); //hard coder... but ez peasy la. Response.TransmitFile(fileName); Response.End(); return(RedirectToAction("Index")); }
public ServiceResult SeansGuncelle(SeanceDTO dto) { var seance = _uow.GetRepository <Seance>().Get(dto.Id); DtotoSeance(dto, seance); ServiceResult result; try { Seance islemYapildiMi = _uow.GetRepository <Seance>().Update(seance); if (islemYapildiMi != null) { result = new ServiceResult("İşlem Başarılıdır.", ResultState.Success); } else { result = new ServiceResult("Yapılacak bir işlem kaydına rastlanamadı", ResultState.Warning); } } catch (Exception ex) { result = new ServiceResult("Hata", ResultState.Error); } return(result); }
// GET: Seances/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Seance seance = unitOfWork.SeanceRepository.ObtenirSeanceParID(id); if (seance == null) { return(HttpNotFound()); } SelectList AgentId = new SelectList(unitOfWork.AgentRepository.ObtenirAgent(), "AgentId", "Nom", seance.AgentId); ViewBag.AgentId = AgentId; SelectList ProprieteId = new SelectList(unitOfWork.ProprieteRepository.ObtenirPropriete(), "ProprieteId", "Adresse", seance.ProprieteId); ViewBag.ProprieteId = ProprieteId; SelectList ForfaitId = new SelectList(unitOfWork.ForfaitRepository.ObtenirForfait(), "ForfaitId", "Nom", seance.ForfaitId); ViewBag.ForfaitId = ForfaitId; return(View(seance)); }
public async Task <ActionResult> SeanceOrder(int?seanceId) { if (seanceId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Seance seance = await db.Seances.GetByIdAsync(seanceId); if (seance == null) { return(HttpNotFound()); } int selectedIndex = 1; seance.Movie = await db.Movies.GetByIdAsync(seance.MovieId); Hall hall = await db.Halls.GetByIdAsync(seance.HallId); hall.Cinema = await db.Cinemas.GetByIdAsync(hall.CinemaId); seance.Hall = hall; SelectList rows = new SelectList(seance.Hall.Rows.OrderBy(r => r.Number), "Id", "Number", null); ViewBag.Rows = rows; SelectList seats = new SelectList(seance.Seats.Where(s => s.IsBooked == false && s.Row.Number == selectedIndex), "Id", "Number", null); ViewBag.Seats = seats; return(View(seance)); }