Esempio n. 1
0
        public IActionResult Edit(int id, [Bind("Id,Name,StartDateTime,EndDateTime,Description,SpeakerId")] Presentation presentation)
        {
            if (id != presentation?.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _presentationRepository.Update(presentation);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PresentationExists(presentation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SpeakerId"] = new SelectList(_speakerRepository.GetAllSpeakers(), "Id", "Id", presentation?.SpeakerId);
            return(View(presentation));
        }
        public IActionResult Put(int id, [FromBody] Presentation presentation)
        {
            if (presentation == null || presentation.Id != id)
            {
                return(BadRequest());
            }

            var todo = repo.Get(id);

            if (todo == null)
            {
                return(NotFound());
            }

            repo.Update(presentation);
            return(new NoContentResult());
        }
Esempio n. 3
0
 public DataModel.Response.BaseResponse UpdatePresentation(DataModel.Model.PresentationModel presentation)
 {
     try
     {
         IPresentationRepository preRepository = RepositoryClassFactory.GetInstance().GetPresentationRepository();
         var _pre = MapperUtil.CreateMapper().Mapper.Map <PresentationModel, Presentation>(presentation);
         preRepository.Update(_pre);
         return(new BaseResponse
         {
             ErrorCode = (int)ErrorCode.None,
             Message = Resources.Resource.msg_update_success
         });
     }
     catch (Exception ex)
     {
         return(new BaseResponse
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }