Ejemplo n.º 1
0
 public ActionResult AddStory(Story input)
 {
     if (ModelState.IsValid)
     {
         using (var db = new AnthonyEntities())
         {
             var storys    = db.Storys.FirstOrDefault(x => x.StoryId == input.StoryId);
             var newStorys = new Story();
             if (storys != null)
             {
                 newStorys.StoryId    = Guid.NewGuid();
                 newStorys.DatePosted = DateTime.Now;
                 if (input != null)
                 {
                     newStorys.StoryId     = new Guid();
                     newStorys.Story1      = input.Story1;
                     newStorys.StoryTeller = input.StoryTeller;
                     newStorys.DateOfStory = input.DateOfStory;
                 }
                 db.Storys.Add(newStorys);
                 db.SaveChanges();
                 return(RedirectToAction("Index", "Home"));
             }
         }
     }
     return(View(input));
 }
Ejemplo n.º 2
0
        //[HttpGet]
        //[ValidateAntiForgeryToken]
        public ActionResult CreateVisitor(Visitors input)
        {
            if (ModelState.IsValid)
            {
                using (var db = new AnthonyEntities())
                {
                    var newVisitors = new Visitor();
                    if (input == null)
                    {
                        newVisitors.VisitorId = Guid.NewGuid();
                        newVisitors.Message   = input.Message;
                        newVisitors.Name      = input.Name;

                        //newVisitors.DatePosted = DateTime.Now;

                        db.Visitors.Add(newVisitors);
                        db.SaveChanges();
                        return(RedirectToAction("Visitors", "Home"));
                    }
                }
            }
            return(View(input));
        }
Ejemplo n.º 3
0
        //[ValidateAntiForgeryToken]
        public ActionResult UploadPicture(Pictures input)
        {
            if (ModelState.IsValid)
            {
                using (var db = new AnthonyEntities())
                {
                    var pictures    = db.Pictures.FirstOrDefault(x => x.PictureId == input.PictureId);
                    var newPictures = new Picture();
                    if (pictures == null)
                    {
                        //newPictures.PictureId = Guid.NewGuid();


                        //if (input != null)
                        //{
                        newPictures.PictureId = new System.Guid();
                    }
                    newPictures.PictureUrl        = input.PictureUrl;
                    newPictures.Caption           = input.Caption;
                    newPictures.DateOfPicture     = input.DateOfPicture;
                    newPictures.VisitorName       = input.VisitorName;
                    newPictures.DatePicturePosted = DateTime.Now;

                    //}
                    if (pictures == null)
                    {
                        return(RedirectToAction("UploadPicture", "Home"));
                    }

                    db.Pictures.Add(newPictures);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View());
        }