public IActionResult Edit(KudoFormViewModel kudoForm) { if (ModelState.IsValid) { Kudo kudo = kudoMapper.MapKudoFormViewModelToModel(kudoForm); if (kudoForm.KudoViewModel.Id.HasValue) { kudoService.ChangeKudo(kudo); } else { User sender = userService.GetUser(this.User); kudoService.CreateKudo(kudo, sender); } kudoService.SaveChanges(); return(RedirectToAction("Index")); } else { kudoMapper.FillKudoFormViewModel(kudoForm); return(View(kudoForm)); } }
public Task <ISlackResponseMessage> Handle(CreateKudoCommand request, CancellationToken cancellationToken) { try { KudoSlashCommandValidatorFactory <CreateKudoCommand> .GetValidator().Validate(request); var kudo = new Domain.Model.Kudo { UserId = request.GetUserId(), Username = request.GetUsername(), ByUserId = request.UserId, ByUsername = request.Username, ChannelId = request.ChannelId, ChannelName = request.ChannelName, CommandText = request.Text }; return(Task.FromResult(kudoService.CreateKudo(kudo))); } catch (Exception ex) { throw; } }