Beispiel #1
0
        public ActionResult Edit([Bind(Include = "SpotGuid,SpotName,Description,Longitude,Latitude,TypeGuid")] SpotEditViewModel spotEditViewModel)
        {
            var spotTypeFind = dbSpotTypes.SpotsTypes.First(x => x.SpotGuid == spotEditViewModel.SpotGuid);

            var spotTypeGuid = spotTypeFind.SpotTypeGuid;

            if (ModelState.IsValid)
            {
                Spot spot = db.Spots.Find(spotEditViewModel.SpotGuid);
                spot.SpotName    = spotEditViewModel.SpotName;
                spot.Description = spotEditViewModel.Description;
                spot.Longitude   = spotEditViewModel.Longitude;
                spot.Latitude    = spotEditViewModel.Latitude;

                spot.DateModified   = DateTime.Now;
                spot.UserModifiedID = Auxiliaries.GetUserId(User);

                SpotType spotType = dbSpotTypes.SpotsTypes.Find(spotTypeGuid);
                spotType.TypeGuid     = spotEditViewModel.TypeGuid;
                spotType.DateModified = DateTime.Now;

                db.Entry(spot).State = EntityState.Modified;
                db.SaveChanges();

                dbSpotTypes.Entry(spotType).State = EntityState.Modified;
                dbSpotTypes.SaveChanges();

                return(RedirectToAction("Index"));
            }
            ViewBag.TypeGuid = new SelectList(dbTypes.Types, "TypeGuid", "TypeName", spotEditViewModel.TypeGuid);
            return(View(spotEditViewModel));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "SpotName,Description,Longitude,Latitude,TypeGuid")] Spot spot)
        {
            if (ModelState.IsValid)
            {
                spot.SpotGuid       = Guid.NewGuid();
                spot.DateCreated    = DateTime.Now;
                spot.DateModified   = spot.DateCreated;
                spot.UserCreatedID  = Auxiliaries.GetUserId(User);
                spot.UserModifiedID = Auxiliaries.GetUserId(User);

                SpotType spotType = new SpotType();
                spotType.SpotTypeGuid = Guid.NewGuid();
                spotType.SpotGuid     = spot.SpotGuid;
                spotType.TypeGuid     = spot.TypeGuid;
                spotType.DateCreated  = DateTime.Now;
                spotType.DateModified = spotType.DateCreated;

                db.Spots.Add(spot);
                db.SaveChanges();

                dbSpotTypes.SpotsTypes.Add(spotType);
                dbSpotTypes.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.TypeGuid = new SelectList(dbTypes.Types, "TypeGuid", "TypeName", spot.TypeGuid);
            return(View(spot));
        }
        public ActionResult Edit([Bind(Include = "PhotoGuid,SpotGuid,Description,Longitude,Latitude,File")] PhotoEditViewModel photoEditViewModel)
        {
            if (ModelState.IsValid)
            {
                Photo photo = db.Photos.Find(photoEditViewModel.PhotoGuid);
                photo.PhotoGuid   = photoEditViewModel.PhotoGuid;
                photo.Spot        = photoEditViewModel.Spot;
                photo.Description = photoEditViewModel.Description;
                photo.Longitude   = photoEditViewModel.Longitude;
                photo.Latitude    = photoEditViewModel.Latitude;

                photo.DateModified   = DateTime.Now;
                photo.UserModifiedID = Auxiliaries.GetUserId(User);

                ViewBag.SpotGuid = new SelectList(db.Spots, "SpotGuid", "SpotName", photoEditViewModel.SpotGuid);

                // Handle the photo
                if (photoEditViewModel.File != null && photoEditViewModel.File.ContentLength > 0)
                {
                    if (!Auxiliaries.ValidImageTypes.Contains(photoEditViewModel.File.ContentType))
                    {
                        ModelState.AddModelError("File", "Izberite sliko, ki je v enem od naštetih formatov: GIF, JPG, ali PNG.");
                        if (photo.File != null && photo.File.Length > 0)
                        {
                            photoEditViewModel.File = new MemoryPostedFile(photo.File);

                            var base64 = Convert.ToBase64String(photo.File);
                            var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
                            ViewBag.ImgSrc = imgSrc;
                        }
                        return(View(photoEditViewModel));
                    }
                    else
                    {
                        using (var reader = new BinaryReader(photoEditViewModel.File.InputStream))
                        {
                            photo.File = reader.ReadBytes(photoEditViewModel.File.ContentLength);
                            int                  thumbWidth    = 250;
                            int                  thumbHeight   = 200;
                            MemoryStream         myMemStream   = new MemoryStream(photo.File);
                            System.Drawing.Image fullsizeImage = System.Drawing.Image.FromStream(myMemStream);
                            System.Drawing.Image newImage      = fullsizeImage.GetThumbnailImage(thumbWidth, thumbHeight, null, IntPtr.Zero);
                            MemoryStream         myResult      = new MemoryStream();
                            newImage.Save(myResult, System.Drawing.Imaging.ImageFormat.Jpeg);
                            byte[] myResultByte = myResult.ToArray();
                            photo.Thumbnail = myResultByte;
                        }
                    }
                }

                db.Entry(photo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(photoEditViewModel));
        }
Beispiel #4
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email, DateCreated = DateTime.Now
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    IDictionary <string, object> dicVal = new Dictionary <string, object>();
                    dicVal.Add("userId", user.Id);
                    dicVal.Add("code", code);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new RouteValueDictionary(dicVal), "http", urlAddress, true);

                    await UserManager.SendEmailAsync(
                        user.Id,
                        "Confirm your account",
                        "<p>Welcome to the <span style=\"font-weight:bold; color:#000080\"> MACA</span> portal!</p> " +
                        "<br />" +
                        "<p>Please, confirm your account by clicking <a href=\"" + callbackUrl + "\">THIS.</a></p>"
                        );

                    // Uncomment to debug locally
                    //ViewBag.Link = callbackUrl;

                    //ViewBag.Message = "Check your email and confirm your account, you must be confirmed "
                    //   + "before you can log in.";
                    ViewBag.Message = "Check your email and confirm the address. Only confirmed users can log in.";

                    Auxiliaries.AddEvent(dbEvents, dbEventTypes, "REG", Request.UserHostAddress, Request.UserHostName, User.Identity);

                    return(View("Info"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult Edit([Bind(Include = "EntityGuid,EntityName,Description")] EntityEditViewModel entityEditViewModel)
        {
            if (ModelState.IsValid)
            {
                Entity entity = db.Entities.Find(entityEditViewModel.EntityGuid);
                entity.EntityName  = entityEditViewModel.EntityName;
                entity.Description = entityEditViewModel.Description;

                entity.DateModified   = DateTime.Now;
                entity.UserModifiedID = Auxiliaries.GetUserId(User);

                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(entityEditViewModel));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "FaqID,Title,Question,Answer,Author")] FAQ faq)
        {
            if (ModelState.IsValid)
            {
                faq.FaqID = Guid.NewGuid();

                faq.DateCreated    = DateTime.Now;
                faq.DateModified   = DateTime.Now;
                faq.UserCreatedID  = Auxiliaries.GetUserId(User);
                faq.UserModifiedID = Auxiliaries.GetUserId(User);

                db.FAQs.Add(faq);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(faq));
        }
        public ActionResult Create([Bind(Include = "EntityName,Description")] Entity entity)
        {
            if (ModelState.IsValid)
            {
                entity.EntityGuid = Guid.NewGuid();

                entity.DateCreated    = DateTime.Now;
                entity.DateModified   = entity.DateCreated;
                entity.UserCreatedID  = Auxiliaries.GetUserId(User);
                entity.UserModifiedID = Auxiliaries.GetUserId(User);

                db.Entities.Add(entity);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(entity));
        }
        public ActionResult Edit([Bind(Include = "TypeGuid,EntityGuid,PinGuid,TypeName,Description")] TypeEditViewModel typeEditViewModel)
        {
            if (ModelState.IsValid)
            {
                Models.Type type = db.Types.Find(typeEditViewModel.TypeGuid);
                type.TypeName    = typeEditViewModel.TypeName;
                type.Description = typeEditViewModel.Description;

                type.DateModified   = DateTime.Now;
                type.UserModifiedID = Auxiliaries.GetUserId(User);

                db.Entry(type).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.EntityGuid = new SelectList(db.Entities, "EntityGuid", "EntityName", typeEditViewModel.EntityGuid);
            ViewBag.PinGuid    = new SelectList(db.Pins, "PinGuid", "Name", typeEditViewModel.PinGuid);
            return(View(typeEditViewModel));
        }
Beispiel #9
0
        public ActionResult Create([Bind(Include = "SpotGuid,Title,Text")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                comment.CommentGuid = Guid.NewGuid();

                comment.DateCreated    = DateTime.Now;
                comment.DateModified   = comment.DateCreated;
                comment.UserCreatedID  = Auxiliaries.GetUserId(User);
                comment.UserModifiedID = Auxiliaries.GetUserId(User);

                db.Comments.Add(comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SpotGuid = new SelectList(db.Spots, "SpotGuid", "SpotName", comment.SpotGuid);
            return(View(comment));
        }
Beispiel #10
0
        public ActionResult Edit([Bind(Include = "CommentGuid,SpotGuid,Title,Text")] CommentEditViewModel commentEditViewModel)
        {
            if (ModelState.IsValid)
            {
                Comment comment = db.Comments.Find(commentEditViewModel.CommentGuid);
                comment.SpotGuid = commentEditViewModel.SpotGuid;
                comment.Title    = commentEditViewModel.Title;
                comment.Text     = commentEditViewModel.Text;

                comment.DateModified   = DateTime.Now;
                comment.UserModifiedID = Auxiliaries.GetUserId(User);

                db.Entry(comment).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.SpotGuid = new SelectList(db.Spots, "SpotGuid", "SpotName", commentEditViewModel.SpotGuid);
            return(View(commentEditViewModel));
        }
Beispiel #11
0
        public ActionResult Edit([Bind(Include = "FaqID,Title,Question,Answer,Author")] FAQViewModel faqView)
        {
            if (ModelState.IsValid)
            {
                FAQ faq = db.FAQs.Find(faqView.FaqID);
                faq.Title    = faqView.Title;
                faq.Question = faqView.Question;
                faq.Answer   = faqView.Answer;
                faq.Author   = faqView.Author;

                faq.DateModified   = DateTime.Now;
                faq.UserModifiedID = Auxiliaries.GetUserId(User);

                db.Entry(faq).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(faqView));
        }
Beispiel #12
0
        private void AppendTrace(EnumTraceType traceType, string message)
        {
            // Add time stamp in the beginning of the trace record
            string timeStamp = "[ " + Auxiliaries.TimeStampGenerate() + " ]";

            // Trace type
            string typeStr = string.Empty;

            switch (traceType)
            {
            case EnumTraceType.Information:
                typeStr = "[INF]";
                break;

            case EnumTraceType.Error:
                typeStr = "[ERR]";
                break;

            case EnumTraceType.Exception:
                typeStr = "[EXC]";
                break;

            case EnumTraceType.Message:
                typeStr = "[MSG]";
                break;
            }

            // Trace body
            if (!message.EndsWith("\n"))
            {
                message += "\n";
            }

            string traceRecord = timeStamp + " " + typeStr + "   " + message;

            this.traceRecord.Append(traceRecord);
            NotifyPropertyChanged("TraceRecord");

            if (UpdateTrace != null)
            {
                UpdateTrace(traceRecord);
            }
        }
        public ActionResult Edit([Bind(Include = "PinGuid,Name,Icon,Color,Description")] PinEditViewModel pinEditViewModel)
        {
            if (ModelState.IsValid)
            {
                Pin pin = db.Pins.Find(pinEditViewModel.PinGuid);
                pin.Name        = pinEditViewModel.Name;
                pin.Color       = pinEditViewModel.Color;
                pin.Description = pinEditViewModel.Description;

                pin.DateModified   = DateTime.Now;
                pin.UserModifiedID = Auxiliaries.GetUserId(User);

                // Handle the image
                if (pinEditViewModel.Icon != null && pinEditViewModel.Icon.ContentLength > 0)
                {
                    if (!Auxiliaries.ValidImageTypes.Contains(pinEditViewModel.Icon.ContentType))
                    {
                        ModelState.AddModelError("Icon", "Izberite sliko, ki je v enem od naštetih formatov: GIF, JPG, ali PNG.");
                        if (pin.Icon != null && pin.Icon.Length > 0)
                        {
                            pinEditViewModel.Icon = new MemoryPostedFile(pin.Icon);

                            var base64 = Convert.ToBase64String(pin.Icon);
                            var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
                            ViewBag.ImgSrc = imgSrc;
                        }
                        return(View(pinEditViewModel));
                    }
                    else
                    {
                        using (var reader = new BinaryReader(pinEditViewModel.Icon.InputStream))
                        {
                            pin.Icon = reader.ReadBytes(pinEditViewModel.Icon.ContentLength);
                        }
                    }
                }

                db.Entry(pin).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(pinEditViewModel));
        }
Beispiel #14
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Require the user to have a confirmed email before they can log on.
            var user = await UserManager.FindByEmailAsync(model.Email);

            if (user != null)
            {
                if (!await UserManager.IsEmailConfirmedAsync(user.Id))
                {
                    //ViewBag.errorMessage = "You must have a confirmed email to log on.";
                    ViewBag.errorMessage = "Za prijavo morate potrditi svoj e-poštni naslov.";
                    return(View("Error"));
                }
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                Auxiliaries.AddEvent(dbEvents, dbEventTypes, "LOG_IN", Request.UserHostAddress, Request.UserHostName, User.Identity);
                return(RedirectToLocal(returnUrl));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Prijava je bila neuspešna.");
                return(View(model));
            }
        }
        public ActionResult Create([Bind(Include = "EntityGuid,PinGuid,TypeName,Description")] Models.Type type)
        {
            if (ModelState.IsValid)
            {
                type.TypeGuid = Guid.NewGuid();

                type.DateCreated    = DateTime.Now;
                type.DateModified   = type.DateCreated;
                type.UserCreatedID  = Auxiliaries.GetUserId(User);
                type.UserModifiedID = Auxiliaries.GetUserId(User);

                db.Types.Add(type);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EntityGuid = new SelectList(db.Entities, "EntityGuid", "EntityName", type.EntityGuid);
            ViewBag.PinGuid    = new SelectList(db.Pins, "PinGuid", "Name", type.PinGuid);
            return(View(type));
        }
        public ActionResult Create([Bind(Include = "Name,Icon,Color,Description")] PinViewModel pinViewModel)
        {
            if (ModelState.IsValid)
            {
                Pin pin = new Pin();
                pin.PinGuid     = Guid.NewGuid();
                pin.Name        = pinViewModel.Name;
                pin.Color       = pinViewModel.Color;
                pin.Description = pinViewModel.Description;

                pin.DateCreated    = DateTime.Now;
                pin.DateModified   = DateTime.Now;
                pin.UserCreatedID  = Auxiliaries.GetUserId(User);
                pin.UserModifiedID = Auxiliaries.GetUserId(User);

                // Handle the icon
                if (pinViewModel.Icon != null && pinViewModel.Icon.ContentLength > 0)
                {
                    if (!Auxiliaries.ValidImageTypes.Contains(pinViewModel.Icon.ContentType))
                    {
                        ModelState.AddModelError("Icon", "Izberite sliko, ki je v enem od naštetih formatov: GIF, JPG, ali PNG.");
                        return(View(pinViewModel));
                    }
                    else
                    {
                        using (var reader = new BinaryReader(pinViewModel.Icon.InputStream))
                        {
                            pin.Icon = reader.ReadBytes(pinViewModel.Icon.ContentLength);
                        }
                    }
                }

                db.Pins.Add(pin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pinViewModel));
        }
        public ActionResult Index(string sortOrder, int?page, [Bind(Include = "SpotName,Description,Longitude,Latitude,TypeGuid")] Spot spot)
        {
            if (ModelState.IsValid)
            {
                spot.SpotGuid       = Guid.NewGuid();
                spot.DateCreated    = DateTime.Now;
                spot.DateModified   = spot.DateCreated;
                spot.UserCreatedID  = Auxiliaries.GetUserId(User);
                spot.UserModifiedID = Auxiliaries.GetUserId(User);

                SpotType spotType = new SpotType();
                spotType.SpotTypeGuid = Guid.NewGuid();
                spotType.SpotGuid     = spot.SpotGuid;
                spotType.TypeGuid     = spot.TypeGuid;
                spotType.DateCreated  = DateTime.Now;
                spotType.DateModified = spotType.DateCreated;

                dbSpots.Spots.Add(spot);
                dbSpots.SaveChanges();

                dbSpotTypes.SpotsTypes.Add(spotType);
                dbSpotTypes.SaveChanges();
            }

            string MarkersString = "[";

            var SpotArray = from x in dbSpots.Spots
                            select new { x.SpotGuid, x.SpotName, x.Latitude, x.Longitude, x.Description };

            var SpotTypes = dbSpotTypes.SpotsTypes;

            foreach (var i in SpotArray)
            {
                MarkersString += "{";
                MarkersString += String.Format("title: '{0}',", i.SpotName);
                MarkersString += String.Format("lat: '{0}',", i.Latitude);
                MarkersString += String.Format("lng: '{0}',", i.Longitude);
                MarkersString += String.Format("description: '{0}',", i.Description);
                foreach (var item in SpotTypes)
                {
                    if (i.SpotGuid == item.SpotGuid)
                    {
                        var Types = dbTypes.Types.First(x => x.TypeGuid == item.TypeGuid);
                        if (Types.TypeName == "Zanimivost")
                        {
                            MarkersString += String.Format("url: '{0}'", "/Images/pinBlue.png");
                        }
                        else if (Types.TypeName == "Zapostavljena mesta")
                        {
                            MarkersString += String.Format("url: '{0}'", "/Images/pinRed.png");
                        }
                        else if (Types.TypeName == "Urejena zapostavljena mesta")
                        {
                            MarkersString += String.Format("url: '{0}'", "/Images/pinGreen.png");
                        }
                    }
                }
                MarkersString += "},";
            }

            MarkersString  += "]";
            ViewBag.Markers = MarkersString;

            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            var spots = from s in dbSpots.Spots
                        select s;

            List <SpotLight> spotLight = new List <SpotLight>();

            foreach (var item in spots)
            {
                SpotLight itemLight = new SpotLight();
                itemLight.SpotGuid = item.SpotGuid;

                foreach (var item2 in SpotTypes)
                {
                    if (item.SpotGuid == item2.SpotGuid)
                    {
                        var Types = dbTypes.Types.First(x => x.TypeGuid == item2.TypeGuid);
                        if (Types.TypeName == "Zanimivost")
                        {
                            itemLight.Style = "Type-Blue";
                        }
                        else if (Types.TypeName == "Zapostavljena mesta")
                        {
                            itemLight.Style = "Type-Red";
                        }
                        else if (Types.TypeName == "Urejena zapostavljena mesta")
                        {
                            itemLight.Style = "Type-Green";
                        }
                    }
                }
                spotLight.Add(itemLight);
            }

            ViewBag.SpotLight = spotLight;

            switch (sortOrder)
            {
            case "name_desc":
                spots = spots.OrderByDescending(s => s.SpotName);
                break;

            case "Date":
                spots = spots.OrderBy(s => s.DateCreated);
                break;

            case "date_desc":
                spots = spots.OrderByDescending(s => s.DateCreated);
                break;

            default:
                spots = spots.OrderBy(s => s.SpotName);
                break;
            }

            int pageSize   = 6;
            int pageNumber = (page ?? 1);

            ViewBag.SpotList = spots.ToPagedList(pageNumber, pageSize);

            if (ModelState.IsValid)
            {
                ModelState.Clear();
            }
            else
            {
                TryUpdateModel(spot);
            }

            ViewBag.TypeGuid = new SelectList(dbTypes.Types, "TypeGuid", "TypeName", spot.TypeGuid);

            return(View());
        }
        public ActionResult Details([Bind(Include = "SpotGuid,Title,Text")] Comment comment, Guid?id)
        {
            if (ModelState.IsValid)
            {
                comment.CommentGuid    = Guid.NewGuid();
                comment.SpotGuid       = id.Value;
                comment.DateCreated    = DateTime.Now;
                comment.DateModified   = comment.DateCreated;
                comment.UserCreatedID  = Auxiliaries.GetUserId(User);
                comment.UserModifiedID = Auxiliaries.GetUserId(User);

                dbComments.Comments.Add(comment);
                dbComments.SaveChanges();
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Spot spot = dbSpots.Spots.Find(id);

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

            var SpotTypes = dbSpotTypes.SpotsTypes;

            string MarkerString = "{";

            MarkerString += String.Format("title: '{0}', ", spot.SpotName);
            MarkerString += String.Format("lat: '{0}', ", spot.Latitude);
            MarkerString += String.Format("lng: '{0}', ", spot.Longitude);
            MarkerString += String.Format("description: '{0}',", spot.Description);
            foreach (var item in SpotTypes)
            {
                if (spot.SpotGuid == item.SpotGuid)
                {
                    var Types = dbTypes.Types.First(x => x.TypeGuid == item.TypeGuid);
                    if (Types.TypeName == "Zanimivost")
                    {
                        MarkerString += String.Format("url: '{0}'", "/Images/pinBlue.png");
                    }
                    else if (Types.TypeName == "Zapostavljena mesta")
                    {
                        MarkerString += String.Format("url: '{0}'", "/Images/pinRed.png");
                    }
                    else if (Types.TypeName == "Urejena zapostavljena mesta")
                    {
                        MarkerString += String.Format("url: '{0}'", "/Images/pinGreen.png");
                    }
                }
            }
            MarkerString += "}";

            ViewBag.Marker = MarkerString;

            var spots    = dbSpots.Spots.Where(x => x.SpotGuid == id.Value);
            var comments = dbComments.Comments.Where(x => x.SpotGuid == id.Value);
            var photos   = dbPhotos.Photos.Where(x => x.SpotGuid == id.Value);

            foreach (var item in spots)
            {
                item.SpotAuthorUsername = dbApp.Users.Find(item.UserCreatedID.ToString()).UserName;
            }
            ViewBag.Spots = spots;

            foreach (var item in comments)
            {
                item.CommentAuthorUsername = dbApp.Users.Find(item.UserCreatedID.ToString()).UserName;
            }
            ViewBag.Comments = comments;

            List <PhotoLight> photosLight = new List <PhotoLight>();

            foreach (var item in photos)
            {
                PhotoLight itemLight = new PhotoLight();
                itemLight.PhotoGuid   = item.PhotoGuid;
                itemLight.Description = item.Description;
                itemLight.DateCreated = item.DateCreated;
                if (item.Thumbnail != null && item.Thumbnail.Length > 0)
                {
                    var base64 = Convert.ToBase64String(item.Thumbnail);
                    var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
                    itemLight.ThumbnailSrc = imgSrc;
                }
                photosLight.Add(itemLight);
            }

            ViewBag.PhotosLight = photosLight;

            if (ModelState.IsValid)
            {
                ModelState.Clear();
            }
            else
            {
                TryUpdateModel(comment);
            }

            return(View());
        }