public async Task <IActionResult> Post(EventDTO events)
        {
            //events.Id = Guid.NewGuid();
            events.OccuredAt = DateTime.UtcNow;

            await _services.AddAsync(Guid.NewGuid(), events.OccuredAt, events.Description, events.Category
                                     , events.UserId, events.Content);

            return(Accepted($"Event Created"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Event(ViewModel.InformationViewModel vmodel, IList <IFormFile> files)
        {
            if (ModelState.IsValid)
            {
                int?Exhibition;
                int?Eduction;
                int?Place;
                int?Address, Cermoney;



                vmodel.Event.EventNow       = DateTime.Now;
                vmodel.Event.StatuseChecked = true;
                vmodel.Event.StatuseEnter   = true;
                vmodel.Event.Statusevent    = WebEventoo_DomainClasses.Model.Event.StatuseEvent.Published;


                if (files == null || files.Count == 0)
                {
                    return(BadRequest());
                }
                vmodel.Event.Image = new List <WebEventoo_DomainClasses.Model.Images>();
                using (var ms = new MemoryStream())
                {
                    foreach (var item in files)
                    {
                        item.CopyTo(ms);
                        var ArrayImage = ms.ToArray();


                        vmodel.Event.Image.Add(new WebEventoo_DomainClasses.Model.Images()
                        {
                            ImageData = ArrayImage, NameImage = item.FileName
                        });



                        // vmodel.Event.Image = vmodel.Image;
                    }
                }
                Exhibition = int.Parse(vmodel.ExhibitionCode);
                // Eduction = int.Parse(vmodel.EductionCode);
                Place    = int.Parse(vmodel.PlaceCode);
                Address  = int.Parse(vmodel.AddressCode);
                Cermoney = int.Parse(vmodel.CermoneyCode);
                //if (Exhibition >= 1)
                //{
                // var ex = context.Exhibition.Where(x => x.Id == Exhibition).Select(x=>new {x.Name,x.Type }).ToList();
                //// vmodel.Event.Exhibotion = ex;
                vmodel.Event.Exhibotion = context.Exhibition.ToList().Where(x => x.Id == Exhibition).ToList();
                vmodel.Event.Place      = context.Place.ToList().Where(x => x.Id == Place).ToList();
                vmodel.Event.Address    = context.Address.ToList().Where(x => x.Id == Address).ToList();
                vmodel.Event.Cermoney   = context.Cermoney.ToList().Where(x => x.Id == Cermoney).ToList();
                //  var xdfdfdf = vmodel.Event;


                await FEventServices.AddAsync(vmodel.Event);

                Message = string.Format("Ok!");
                // return View("Event");
                return(RedirectToAction("Index"));

                //   }
            }
            return(View());
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <Event> > PostTodoItem(Event item)
        {
            await Event.AddAsync(item);

            return(CreatedAtAction(nameof(Event), new { id = item.Id }, item));
        }