예제 #1
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Usher usher = db.Ushers.Find(id);

            if (usher == null)
            {
                return(HttpNotFound());
            }

            var model = new UsherViewModel
            {
                UsherId         = usher.UsherId,
                FirstName       = usher.FirstName,
                LastName        = usher.LastName,
                MobileNumber    = usher.MobileNumber,
                DateOfBirth     = usher.DateOfBirth,
                Gender          = usher.Gender,
                Nationality     = usher.Nationality,
                City            = usher.City,
                CarAvailability = usher.CarAvailability,
                MedicalCard     = usher.MedicalCard,
                Language        = usher.Language.Name,
            };

            return(View(model));
        }
예제 #2
0
        public ActionResult Edit(UsherViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Validating the date of birth
                if (model.DateOfBirth > DateTime.Today.AddYears(-15))
                {
                    // The message will be displayed in @Html.ValidationMessageFor(m => m.CreationDate)
                    ModelState.AddModelError("DateOfBirth", "The usher should be 16 years old or above. ");

                    // The message will be displayed in @Html.ValidationSummary()
                    ModelState.AddModelError(String.Empty, "Issue with the date of birth");

                    return(View(model));
                }

                Usher usher = Mapper.Map <UsherViewModel, Usher>(model);
                db.Entry(usher).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.LanguageId = new SelectList(db.Languages, "Id", "Name", model.LanguageId);
            return(View(model));
        }
예제 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Usher usher = db.Ushers.Find(id);

            db.Ushers.Remove(usher);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
파일: Walkthrough.cs 프로젝트: atil/7dfps20
    public void Init()
    {
        gameObject.SetActive(true);

        RenderSettings.ambientLight = AmbientColor;
        Sfx sfx = FindObjectOfType <Sfx>();

        sfx.MusicAudioSource.volume = HasBackgroundNoise ? Sfx.BaseMusicVolume : 0f;
        sfx.CinemaClick();

        foreach (TriggerBase tb in GetComponentsInChildren <TriggerBase>())
        {
            tb.ResetTrigger();
        }

        Ui ui = FindObjectOfType <Ui>();

        if (HasTransitionFlash)
        {
            ui.TransitionFlash();
        }
        if (HasGlitch)
        {
            ui.ClearFlash();
            const float glitchDuration = 0.5f;
            ui.Glitch(glitchDuration);
            sfx.Glitch(glitchDuration);
        }

        Player player = FindObjectOfType <Player>();

        player.ResetAt(PlayerStart);
        Usher usher = FindObjectOfType <Usher>();

        if (usher != null)
        {
            usher.IsLookingAtPlayer = IsUsherLookingAtPlayer;
            usher.SpookState        = IsUsherSpookyWhenVisible ? UsherSpookState.WaitingToTeleport : UsherSpookState.None;
        }

        UnityEngine.GameObject artworkSlots = UnityEngine.GameObject.Find("ArtworkSlots");
        if (artworkSlots != null)
        {
            Debug.Assert(artworkSlots.transform.childCount == 4);

            for (int i = 0; i < artworkSlots.transform.childCount; i++)
            {
                Transform slot         = artworkSlots.transform.GetChild(i);
                Material  slotMaterial = slot.GetComponent <MeshRenderer>().material;
                slotMaterial.SetTexture("_MainTex", Posters[i]);
            }
        }
    }
예제 #5
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Usher usher = db.Ushers.Find(id);

            if (usher == null)
            {
                return(HttpNotFound());
            }

            UsherViewModel model = Mapper.Map <Usher, UsherViewModel>(usher);

            ViewBag.LanguageId = new SelectList(db.Languages, "Id", "Name", usher.LanguageId);
            return(View(model));
        }
예제 #6
0
        public ActionResult Create(UsherViewModel model)
        {
            if (ModelState.IsValid)
            {
                ViewBag.languageId = new SelectList(db.Languages, "Id", "Name");

                var usher = new Usher
                {
                    FirstName       = model.FirstName,
                    LastName        = model.LastName,
                    MobileNumber    = model.MobileNumber,
                    DateOfBirth     = model.DateOfBirth,
                    Gender          = model.Gender,
                    Nationality     = model.Nationality,
                    City            = model.City,
                    CarAvailability = model.CarAvailability,
                    MedicalCard     = model.MedicalCard,
                    LanguageId      = model.LanguageId,
                };

                // Validating the date of birth
                if (model.DateOfBirth > DateTime.Today.AddYears(-15))
                {
                    // The message will be displayed in @Html.ValidationMessageFor(m => m.CreationDate)
                    ModelState.AddModelError("DateOfBirth", "The usher should be 16 years old or above. ");

                    // The message will be displayed in @Html.ValidationSummary()
                    ModelState.AddModelError(String.Empty, "Issue with the date of birth");

                    return(View(model));
                }

                //TODO Remove invalid characters from the filename such as white spaces
                // check if the uploaded file is empty
                if (model.MedicalCardFile != null && model.MedicalCardFile.ContentLength > 0)
                {
                    // Allowed extensions to be uploaded
                    var extensions = new[] { "pdf", "docx", "doc", "jpg", "jpeg", "png" };

                    // Get the file name without the path
                    string filename = Path.GetFileName(model.MedicalCardFile.FileName);

                    // Get the extension of the file
                    string ext = Path.GetExtension(filename).Substring(1);

                    // Check if the extension of the file is in the list of allowed extensions
                    if (!extensions.Contains(ext, StringComparer.OrdinalIgnoreCase))
                    {
                        ModelState.AddModelError(string.Empty, "Accepted file are pdf, docx, doc, jpg, jpeg, and png documents");
                        return(View());
                    }

                    // Set the application folder where to save the uploaded file
                    string appFolder = "~/Content/Uploads/";

                    // Generate a random string to add to the file name
                    // This is to avoid the files with the same names
                    var rand = Guid.NewGuid().ToString();

                    // Combine the application folder location with the file name
                    string path = Path.Combine(Server.MapPath(appFolder), rand + "-" + filename);

                    // Save the file in ~/Content/Uploads/filename.xyz
                    model.MedicalCardFile.SaveAs(path);

                    // Add the path to the course object
                    usher.MedicalCard = appFolder + rand + "-" + filename;
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Empty files are not accepted");
                    ViewBag.languageId = new SelectList(db.Languages, "Id", "Name");
                    return(View());
                }

                db.Ushers.Add(usher);
                db.SaveChanges();

                ViewBag.languageId = new SelectList(db.Languages, "Id", "Name");
                return(RedirectToAction("Index"));
            }

            ViewBag.languageId = new SelectList(db.Languages, "Id", "Name");
            return(View(model));
        }