public void Create(DialogCreateViewModel model) { try { Dialog dialog = this.Add(new Dialog() { Active = true, Name = model.Name }); IntentService intentService = new IntentService(); int i = 0; foreach (var intentId in model.IntentIds) { Intent intent = intentService.FirstOrDefault(q => q.Id == intentId); intent.DialogId = dialog.Id; intent.Active = true; intent.Step = model.Steps[i]; intent.Exception = model.Exceptions[i]; ++i; } intentService.SaveChanges(); this.DbSet.SaveChanges(); } catch (Exception e) { throw e; } }
public JsonResult Create(DialogCreateViewModel model) { DialogService service = new DialogService(); try { service.Create(model); return(Json(new ResponseMessage() { Message = "Đã tạo thành công", Success = true })); } catch (Exception e) { return(Json(new ResponseMessage() { Message = "Đã có lỗi xảy ra", Success = false })); } }