public IHttpActionResult Post([FromBody] CreateEventAgendaModel model) { var agenda = new EventAgenda { AgendaTitle = model.AgendaTitle, AgendaDescription = model.AgendaDescription, Tentative = model.Tentative, Time = model.Time, EventId = model.EventId, PersonInChargeId = model.PersonInChargeId, CreatedBy = null, Display = true, CreatedDate = DateTime.Now, }; db.EventAgenda.Add(agenda); db.SaveChanges(); //files foreach (var fileid in model.FilesId) { var eventfile = new EventFile { FileCategory = EventFileCategory.EventAgenda, FileId = fileid, ParentId = agenda.Id }; db.EventFile.Add(eventfile); } return(Ok(agenda.Id)); }
public async Task <ActionResult> Create(FEP.Intranet.Areas.eEvent.Models.CreateEventAgendaModel model) { if (ModelState.IsValid) { var modelapi = new CreateEventAgendaModel { AgendaTitle = model.AgendaTitle, AgendaDescription = model.AgendaDescription, Time = model.Time, Tentative = model.Tentative, EventId = model.EventId, PersonInChargeId = model.PersonInChargeId }; //attachment if (model.AttachmentFiles.Count() > 0) { var responseFile = await WepApiMethod.SendApiAsync <List <FileDocument> >($"File?userId={CurrentUser.UserId}", model.AttachmentFiles.ToList()); if (responseFile.isSuccess) { modelapi.FilesId = responseFile.Data.Select(f => f.Id).ToList(); } } var response = await WepApiMethod.SendApiAsync <int>(HttpVerbs.Post, $"eEvent/EventAgenda", modelapi); if (response.isSuccess) { await LogActivity(Modules.Event, "Create Event Agenda", model); TempData["SuccessMessage"] = "Event Agenda successfully created"; return(RedirectToAction("List")); } } model.EventIds = new SelectList(await GetEvent(), "Id", "RefNo"); model.PersonInchargeIds = new SelectList(await GetUsers(), "Id", "Name"); return(View(model)); }