Beispiel #1
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var response = await WepApiMethod.SendApiAsync <EditEventSpeakerModel>(HttpVerbs.Get, $"eEvent/EventSpeaker?id={id}");

            if (!response.isSuccess)
            {
                return(HttpNotFound());
            }

            var model = new FEP.Intranet.Areas.eEvent.Models.EditEventSpeakerModel()
            {
                UserId        = response.Data.UserId,
                UserName      = response.Data.UserName,
                SpeakerType   = response.Data.SpeakerType,
                Experience    = response.Data.Experience,
                SpeakerStatus = response.Data.SpeakerStatus,
                Attachments   = response.Data.Attachments
            };

            model.UserIds = new SelectList(await GetUsers(), "Id", "Name", 0);

            return(View(model));
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(FEP.Intranet.Areas.eEvent.Models.EditEventSpeakerModel model)
        {
            if (model.Attachments.Count() == 0 && model.AttachmentFiles.Count() == 0)
            {
                ModelState.AddModelError("Attachments", "Please upload file");
            }

            if (ModelState.IsValid)
            {
                var modelapi = new EditEventSpeakerModel()
                {
                    UserId        = model.UserId,
                    UserName      = model.UserName,
                    SpeakerType   = model.SpeakerType,
                    SpeakerStatus = model.SpeakerStatus,
                    Experience    = model.Experience,
                    Attachments   = model.Attachments,
                };

                //attachment
                if (model.AttachmentFiles.Count() > 0)
                {
                    var responseFile = await FileMethod.UploadFile(model.AttachmentFiles.ToList(), CurrentUser.UserId);

                    if (responseFile != null)
                    {
                        modelapi.FilesId = responseFile.Select(f => f.Id).ToList();
                    }
                }

                var response = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Put, $"eEvent/EventSpeaker?id={model.Id}", modelapi);

                if (response.isSuccess)
                {
                    //LogActivity("Update Event Speaker", model);

                    TempData["SuccessMessage"] = "Event Speaker successfully updated";

                    return(RedirectToAction("List"));
                }
            }

            model.UserIds = new SelectList(await GetUsers(), "Id", "Name", 0);

            //TempData["ErrorMessage"] = "Fail to update Event Speaker";

            return(View(model));
        }