Ejemplo n.º 1
0
        public ActionResult SubmitForm(VestiViewModel vestiViewModel)
        {
            var vest = new Models.Domain.Vesti()
            {
                Author      = vestiViewModel.Author,
                Name        = vestiViewModel.Name,
                Id          = vestiViewModel.Id,
                Category    = vestiViewModel.Category,
                Description = vestiViewModel.Description
            };


            if (vestiViewModel.Id != 0)
            {
                var res = prodynaService.UpdateVest(vest);
            }
            else
            {
                vest.CreatedTimeStamp = DateTime.Now;

                var res = prodynaService.AddVest(vest);
            }

            var resAfterUpdate = prodynaService.GetAllVesti();

            var indexViewModel = new SveVestiViewModel();

            foreach (var item in resAfterUpdate)
            {
                indexViewModel.SveVesti.Add(new VestiViewModel()
                {
                    Name            = item.Name,
                    Id              = item.Id,
                    Description     = item.Description,
                    Author          = item.Author,
                    Category        = item.Category,
                    FormatTimeStamp = "News published at: " + item.CreatedTimeStamp.Value.Year + "-" + item.CreatedTimeStamp.Value.Month + "-" + item.CreatedTimeStamp.Value.Day + "-" + item.CreatedTimeStamp.Value.Hour + "-" + item.CreatedTimeStamp.Value.Minute + "-" + item.CreatedTimeStamp.Value.Second
                });
            }

            return(View("~/Views/Home/index.cshtml", indexViewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var res = prodynaService.GetAllVesti();



            var indexViewModel = new SveVestiViewModel();

            foreach (var item in res)
            {
                indexViewModel.SveVesti.Add(new VestiViewModel()
                {
                    Name            = item.Name,
                    Id              = item.Id,
                    Description     = item.Description,
                    Author          = item.Author,
                    Category        = item.Category,
                    FormatTimeStamp = "News published at: " + item.CreatedTimeStamp.Value.Year + "-" + item.CreatedTimeStamp.Value.Month + "-" + item.CreatedTimeStamp.Value.Day + "-" + item.CreatedTimeStamp.Value.Hour + "-" + item.CreatedTimeStamp.Value.Minute + "-" + item.CreatedTimeStamp.Value.Second
                });
            }

            return(View(indexViewModel));
        }