Esempio n. 1
0
 static WebSharper.UI.Next.Doc DisplayBookDoc(Book book)
 {
     return(new Template.Index.ListItem()
            .Title(book.Title)
            .Author(book.Author)
            .PublishDate(DateToString(book.PublishDate))
            .ISBN(book.ISBN)
            .Remove(async(el, ev) =>
     {
         Message.Value = $"Removing book '{book.Title}'";
         var res = await Remoting.DeleteBook(book.BookId);
         Books.Remove(book);
         if (res)
         {
             Message.Value = $"Removed book '{book.Title}'";
         }
         else
         {
             Message.Value = $"Book '{book.Title}' was already removed";
         }
     })
            .Edit((el, ev) =>
     {
         book.IsEdited = true;
         Books.Add(book);
     })
            .Doc());
 }
Esempio n. 2
0
        public void TodoApp()
        {
            var Tasks =
                new ListModel <string, TaskItem>(task => task.Name)
            {
                new TaskItem("Have breakfast", true),
                new TaskItem("Have lunch", false)
            };

            var NewTaskName = Var.Create("");

            Template.Template.Main.Doc(
                ListContainer: Tasks.View.DocSeqCached((TaskItem task) =>
                                                       Template.Template.ListItem.Doc(
                                                           Task: task.Name,
                                                           Clear: (el, ev) => Tasks.RemoveByKey(task.Name),
                                                           Done: task.Done,
                                                           ShowDone: attr.@class("checked", task.Done.View, x => x)
                                                           )
                                                       ),
                NewTaskName: NewTaskName,
                Add: (el, ev) =>
            {
                Tasks.Add(new TaskItem(NewTaskName.Value, false));
                NewTaskName.Value = "";
            },
                ClearCompleted: (el, ev) => Tasks.RemoveBy(task => task.Done.Value)
                ).RunById("tasks");
        }
Esempio n. 3
0
        public static void TodoApp()
        {
            var Tasks =
                new ListModel <string, TaskItem>(task => task.Name)
            {
                new TaskItem("Have breakfast", true),
                new TaskItem("Have lunch", false)
            };

            var NewTaskName = Var.Create("");

            new Template.Template.Main()
            .ListContainer(Tasks.View.DocSeqCached((TaskItem task) =>
                                                   new Template.Template.ListItem()
                                                   .Task(task.Name)
                                                   .Clear((el, ev) => Tasks.RemoveByKey(task.Name))
                                                   .Done(task.Done)
                                                   .ShowDone(attr.@class("checked", task.Done.View, x => x))
                                                   .Elt()
                                                   ))
            .NewTaskName(NewTaskName)
            .Add((el, ev) =>
            {
                Tasks.Add(new TaskItem(NewTaskName.Value, false));
                NewTaskName.Value = "";
            })
            .ClearCompleted((el, ev) => Tasks.RemoveBy(task => task.Done.Value))
            .Doc()
            .RunById("tasks");
            new Template.Index.tasksTitle()
            .Doc()
            /* .OnAfterRender(FSharpConvert.Fun<JavaScript.Dom.Element>((el) => JavaScript.Console.Log("test"))) */
            .RunById("tasksTitle");
        }
Esempio n. 4
0
        /// <summary>
        /// Subpage: The content is built up entirely on the client and sent to
        /// the server in a JSON-Compatible data type.
        /// </summary>
        /// <returns></returns>
        public static WebSharper.UI.Doc WithStaticDoc()
        {
            var contentList    = new ListModel <string, string>(s => s);
            var contentTextBox = Var.Create("");

            return(new Template.Withstatic()
                   .ContentTextBox(contentTextBox)
                   .Back((el, ev) =>
            {
                IndexDoc().RunById("page");
            })
                   .ListContainer(
                       contentList.View.DocSeqCached((string x) =>
                                                     new Template.Withstatic.ListItem().Item(x).Doc()
                                                     )
                       )
                   .Submit(async(el, ev) =>
            {
                contentList.Add(contentTextBox.Value);
                contentTextBox.Set("");
                var conent = new List <string>(contentList.Value);
                await StaticRemoting.Put(conent);
            })
                   .Doc());
        }
Esempio n. 5
0
        public override int SetModel(Models.EnemyViewModel model)
        {
            model.InternalEnemyId = ListModel.Count + 1;

            ListModel.Add(model);
            ProjectVikingsContext.UpdateAliveLists();
            return(model.InternalEnemyId);
        }
        private void OnLoad()
        {
            var libraryNames = typeof(LibraryName).GetEnumValues();

            foreach (var item in libraryNames)
            {
                ListModel.Add(new Model()
                {
                    Text = Enum.GetName(typeof(LibraryName), item)
                });
            }
        }
Esempio n. 7
0
 public void ReadInfo(int outkey)
 {
     for (int i = 0; i < dgConsulate.Rows.Count; i++)
     {
         ConDocModel = new ConsulationDoctorsModel();
         ConDocModel.ConsultationUnitName = dgConsulate.Rows[i].Cells[1].Value.ToString();
         ConDocModel.ConsultationDoctor1  = dgConsulate.Rows[i].Cells[2].Value.ToString();
         ConDocModel.ConsultationDoctor2  = dgConsulate.Rows[i].Cells[3].Value.ToString();
         ConDocModel.ConsultationDoctor3  = dgConsulate.Rows[i].Cells[4].Value.ToString();
         ConDocModel.OutKey = outkey;
         ListModel.Add(ConDocModel);
     }
 }
Esempio n. 8
0
 static public IControlBody Main()
 {
     return(doc(
                ul(People.View.DocSeqCached((string x) => li(x))),
                div(
                    input(NewName, attr.placeholder("Name")),
                    button("Add", () =>
     {
         People.Add(NewName.Value);
         NewName.Value = "";
     }),
                    div("You are about to add: ", NewName)
                    )
                ));
 }
Esempio n. 9
0
        public static void TodoApp()
        {
            var Tasks =
                new ListModel <string, TaskItem>(task => task.Name)
            {
                new TaskItem("Have breakfast", 8, true),
                new TaskItem("Have lunch", 6, false)
            };
            var newTaskPriority = Var.Create(5);

            new Template.Template.Main()
            .ListContainer(
                Tasks.View
                .Map(l => (IEnumerable <TaskItem>)l.OrderByDescending(t => t.Priority))
                .DocSeqCached((TaskItem task) => new Template.Template.ListItem()
                              .Task(task.Name)
                              .Priority(task.Priority.ToString())
                              .Clear((el, ev) => Tasks.RemoveByKey(task.Name))
                              .Done(task.Done)
                              .ShowDone(attr.@class("checked", task.Done.View, x => x))
                              .Elt()
                              ))
            .Add((m) =>
            {
                Tasks.Add(new TaskItem(m.Vars.NewTaskName.Value, newTaskPriority.Value, false));
                m.Vars.NewTaskName.Value = "";
            })
            .ClearCompleted((el, ev) => Tasks.RemoveBy(task => task.Done.Value))
            .NewTaskPriority(newTaskPriority)
            .Doc()
            .RunById("tasks");
            new Template.Index.tasksTitle()
            .Elt()
            .OnAfterRender(FSharpConvert.Fun <JavaScript.Dom.Element>((el) => JavaScript.Console.Log("test")))
            .RunById("tasksTitle");
        }
Esempio n. 10
0
 public override int SetModel(Models.PlayerViewModel model)
 {
     ListModel.Add(model);
     MVC_Game2Context.UpdateAliveLists();
     return(model.PlayerId);
 }
Esempio n. 11
0
        public void TodoApp()
        {
            var Tasks =
                new ListModel<string, TaskItem>(task => task.Name) {
                    new TaskItem("Have breakfast", true),
                    new TaskItem("Have lunch", false)
                };

            var NewTaskName = Var.Create("");

            Template.Template.Main.Doc(
                ListContainer: Tasks.View.DocSeqCached((TaskItem task) =>
                    Template.Template.ListItem.Doc(
                        Task: task.Name, 
                        Clear: (el, ev) => Tasks.RemoveByKey(task.Name), 
                        Done: task.Done, 
                        ShowDone: attr.@class("checked", task.Done.View, x => x)
                    )
                ),
                NewTaskName: NewTaskName,
                Add: (el, ev) =>
                {
                    Tasks.Add(new TaskItem(NewTaskName.Value, false));
                    NewTaskName.Value = "";
                },
                ClearCompleted: (el, ev) => Tasks.RemoveBy(task => task.Done.Value)
            ).RunById("tasks");
        }