public async Task CreateTablesAsync(CreateTableModel model)
        {
            var         t1    = subscribersTableOperator.CreateTableAsync(model.SubscribersTable.Read, model.SubscribersTable.Write, model.SubscribersTable.TTLEnabled);
            List <Task> tasks = new List <Task> {
                t1
            };

            if (model.TagsTable.HasValue)
            {
                tasks.Add(tagTableOperator.CreateTableAsync(model.TagsTable.Value.Read, model.TagsTable.Value.Write));
                if (model.IterativeTagsTable.HasValue)
                {
                    tasks.Add(iterativeTagTableOperator.CreateTableAsync(model.IterativeTagsTable.Value.Read, model.IterativeTagsTable.Value.Write, model.IterativeTagsTable.Value.TTLEnabled));
                }
                if (model.SNSTopicTagsTable.HasValue)
                {
                    tasks.Add(snsTopicTagTableOperator.CreateTableAsync(model.SNSTopicTagsTable.Value.Read, model.SNSTopicTagsTable.Value.Write));
                }
            }
            if (model.LogsTable.HasValue)
            {
                tasks.Add(logsTableOperator.CreateTableAsync(model.LogsTable.Value.Read, model.LogsTable.Value.Write));
            }
            await Task.WhenAll(tasks.ToArray());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <CreateTableResult> > Create([FromBody] CreateTableModel model)
        {
            try
            {
                if (model == null)
                {
                    return(new CreateTableResult
                    {
                        Successful = false,
                        Errors = new List <string>()
                        {
                            "Invalid table model"
                        }
                    });
                }

                var table = await _tableRepository.GetTableByName(model.Name);

                if (table != null)
                {
                    return(Ok(new CreateTableResult
                    {
                        Successful = false,
                        Errors = new List <string>()
                        {
                            "Table with this name already exists"
                        }
                    }));
                }

                await _tableRepository.AddTable(_mapper.Map <PokerTable>(model));

                return(Ok(new CreateTableResult
                {
                    Successful = true
                }));
            }
            catch (Exception)
            {
                return(new CreateTableResult
                {
                    Successful = false,
                    Errors = new List <string>()
                    {
                        "Unexpected error occured. Try again or contact support"
                    }
                });
            }
        }
Exemplo n.º 3
0
        public ActionResult Create()
        {
            CreateTableModel model = new CreateTableModel();

            List <Cupcake.Web.Models.ColumnModel> list = new List <Cupcake.Web.Models.ColumnModel>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(new Cupcake.Web.Models.ColumnModel());
            }

            model.ColumnListModel(list);

            return(View(model));
        }
Exemplo n.º 4
0
        public virtual IActionResult Create(CreateTableModel model, bool continueEditing, CancellationToken cancellationToken)
        {
            if (!_permissionService.Authorize(XrmsPermissionProvider.ManageTables))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                /*var group = model.ToEntity();
                 * group.CreatedOnUtc = DateTime.UtcNow;
                 * group.UpdatedOnUtc = DateTime.UtcNow;
                 * _materialGroupService.InsertTable(group);*//*_context.Add(table);
                 * await _context.SaveChangesAsync();
                 * return RedirectToAction("Index");*/
                Guid guid = CompGuid.NewGuid();
                _commandSender.Send(new CreateCmd(guid, "", model.Name, 0, Guid.Empty, model.Description), cancellationToken);
                //return RedirectToAction("Index");



                var table = this._materialGroupService.GetTableByAggregateId(guid);

                //activity log
                _customerActivityService.InsertActivity("AddNewTable", _localizationService.GetResource("Xrms.ActivityLog.AddNewTable"), table);

                SuccessNotification(_localizationService.GetResource("Xrms.Admin.Catalog.Tables.Notifications.Created"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();
                    return(RedirectToAction("Edit", new { id = table.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            var viewModel = new TableDetailsPageViewModel();

            model.ToDetailsViewModel(viewModel);
            //viewModel.TableInfo = model;

            return(View("~/Plugins/Xrms/Areas/Admin/Views/Table/Create.cshtml", viewModel));
        }
Exemplo n.º 5
0
        public async Task <CreateTableResult> Create(CreateTableModel model)
        {
            var result = await _httpClient.PostJsonAsync <CreateTableResult>("api/table", model);

            return(result);
        }
Exemplo n.º 6
0
 public static TableDetailsPageViewModel ToDetailsViewModel(this CreateTableModel model, TableDetailsPageViewModel viewModel)
 {
     return(model.MapTo(viewModel));
 }
Exemplo n.º 7
0
 public static Table ToEntity(this CreateTableModel model, Table entity)
 {
     return(model.MapTo(entity));
 }
Exemplo n.º 8
0
 // from action model to entity
 public static Table ToEntity(this CreateTableModel model)
 {
     return(model.MapTo <CreateTableModel, Table>());
 }