Ejemplo n.º 1
0
        public async Task <IActionResult> EventSave(EventVM model, IFormFile image)
        {
            String fileName = new String("");

            if (image != null && image.Length > 0)
            {
                fileName = Path.GetFileName(image.FileName);
                //var mappedPath = HttpContext.GetServerVariable.MapPath("~/Content/Images/");
                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\items", fileName);
                using (var fajlSteam = new FileStream(path, FileMode.Create))
                {
                    await image.CopyToAsync(fajlSteam);
                }
            }

            if (model.ID == 0)
            {
                var insertRequest = new EventInsertRequest()
                {
                    Name          = model.Name,
                    Description   = model.Description,
                    EventCategory = model.EventCategory,
                    Start         = model.Start,
                    End           = model.Start,
                    IsApproved    = model.IsApproved,
                    IsCanceled    = model.IsCanceled,
                    OrganizerID   = model.OrganizerID,
                    VenueID       = model.VenueID,
                    Image         = fileName
                };

                await _eventiApi.CreateEventAsync(insertRequest);
            }
            else
            {
                var updateRequest = new EventUpdateRequest()
                {
                    Name            = model.Name,
                    Description     = model.Description,
                    EventCategory   = model.EventCategory,
                    Start           = model.Start,
                    End             = model.Start,
                    IsApproved      = model.IsApproved,
                    IsCanceled      = model.IsCanceled,
                    OrganizerID     = model.OrganizerID,
                    AdministratorID = model.AdministratorID,
                    VenueID         = model.VenueID,
                    Image           = fileName
                };

                await _eventiApi.UpdateEventAsync(model.ID, updateRequest);
            }

            return(Redirect("Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> EditEventSave(EventEditVM model)
        {
            var response = await _eventiApi.GetEventAsync(model.ID);

            var e = response.Content;

            var request = new EventUpdateRequest()
            {
                Name          = model.Name,
                Description   = model.Description,
                Start         = model.Start,
                End           = model.End,
                EventCategory = (EventCategory)model.EventCategorySelected
            };

            await _eventiApi.UpdateEventAsync(model.ID, request);


            return(Redirect("EventInfoPrikaz?EventID=" + model.ID.ToString()));
        }