public ActionResult Worksheet(string inputName, string inputSurname, string inputWishes, string inputBrazil, string inputDance, string inputParty, string inputGender)
        {
            SimpleSheet sheet = new SimpleSheet()
            {
                Name    = inputName,
                Surname = inputSurname,
                Wishes  = inputWishes,
                Gender  = inputGender,
            };

            if (inputBrazil == "on")
            {
                sheet.Interests.Add("Brazil");
            }
            if (inputDance == "on")
            {
                sheet.Interests.Add("Dancing");
            }
            if (inputParty == "on")
            {
                sheet.Interests.Add("Party");
            }

            return(View("WorksheetFilled", sheet));
        }
Пример #2
0
        public void TestSimpleSheet()
        {
            SimpleSheet simpleSheet = new SimpleSheet();
            string      str         = simpleSheet.InitSheet(20, 4);

            Assert.NotNull(str);
            Assert.StartsWith("-", str);

            string ret = Utils.CalculateNewOutPut(str, 1, 2, 2);

            Assert.NotNull(ret);
            Assert.StartsWith("-", ret);
            Assert.True(ret.Contains("2"));

            ret = Utils.CalculateNewOutPut(ret, 1, 3, 4);
            Assert.NotNull(ret);
            Assert.StartsWith("-", ret);
            Assert.True(ret.Contains("2"));
            Assert.True(ret.Contains("4"));

            ret = Utils.CalculateSumOutPut(ret, new int[] { 1, 2, 1, 3, 1, 4 });
            Assert.NotNull(ret);
            Assert.StartsWith("-", ret);
            Assert.True(ret.Contains("2"));
            Assert.True(ret.Contains("4"));
            Assert.True(ret.Contains("6"));
        }
Пример #3
0
        public void Delete(int id)
        {
            SimpleSheet SimpleSheet = db.SimpleSheets.Find(id);

            if (SimpleSheet != null)
            {
                db.SimpleSheets.Remove(SimpleSheet);
            }
        }
        public void TestSheetSerialization()
        {
            var model = new SimpleSheet()
            {
                Logic  = true,
                Text   = Guid.NewGuid().ToString(),
                Number = 42
            };

            for (var i = 0; i < 100; i++)
            {
                model.Items.Add(new CollectionItem
                {
                    Index = i,
                    Value = $"Item{i}"
                });
            }

            using (var excelPackage = new ExcelPackage())
            {
                var sheet = excelPackage.Workbook.Worksheets.Add("Sheet1");

                XlsSheetSerializerCore.Serialize(typeof(SimpleSheet), model, sheet, new XlsxSerializerSettings());

                excelPackage.SaveAs(new FileInfo("testsheet1.xlsx"));
            }

            var deserialized = new SimpleSheet();

            using (var excelPackage = new ExcelPackage(new FileInfo("testsheet1.xlsx")))
            {
                XlsSheetDeserializerCore.Deserialize(deserialized, excelPackage.Workbook.Worksheets["Sheet1"], new XlsxSerializerSettings());
            }

            Assert.Equal(model.Logic, deserialized.Logic);
            Assert.Equal(model.Number, deserialized.Number);
            Assert.Equal(model.Text, deserialized.Text);

            Assert.Equal(model.Items.Count, deserialized.Items.Count);

            for (var i = 0; i < model.Items.Count; i++)
            {
                var modelItem = model.Items[i];
                var deseItem  = deserialized.Items[i];

                Assert.Equal(modelItem.Index, deseItem.Index);
                Assert.Equal(modelItem.Value, deseItem.Value);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            bool hasInitSheet = false;//first step must init a sheet

            SimpleSheet simpleSheet = new SimpleSheet();
            string      str = string.Empty;
            int         x = 0, y = 0, z = 0;

            while (true)
            {
                Console.Write("enter command: ", ConsoleColor.Blue);
                string input = Console.ReadLine();
                if (input.ToLower() == "q")
                {
                    Environment.Exit(-1);
                }
                if (string.IsNullOrWhiteSpace(input) || !(input.ToLower().StartsWith("n") || input.ToLower().StartsWith("c") || input.ToLower().StartsWith("s")))
                {
                    Console.Write("error input , please enter command again: ", ConsoleColor.Red);
                    continue;
                }
                string[] arr = input.Split(' ');
                if (arr.Any(a => a.Length > 3))
                {
                    Console.Write("error input each cell will allocate at most 3 characters, please enter command again: ", ConsoleColor.Red);
                    continue;
                }
                x = 0;
                y = 0;
                z = 0;
                if (input.ToLower().StartsWith("c") && arr.Length == 3)
                {
                    if (int.TryParse(arr[1], out x) && int.TryParse(arr[2], out y))
                    {
                        str          = simpleSheet.InitSheet(x, y);
                        hasInitSheet = true;
                        Console.WriteLine(str);
                    }
                }
                else if (hasInitSheet && input.ToLower().StartsWith("n") && arr.Length == 4)
                {
                    if (int.TryParse(arr[1], out x) && int.TryParse(arr[2], out y) && int.TryParse(arr[3], out z))
                    {
                        str = Utils.CalculateNewOutPut(str, x, y, z);
                        Console.WriteLine(str);
                    }
                }
                else if (hasInitSheet && input.ToLower().StartsWith("s") && arr.Length >= 5 && arr.Length % 2 == 1)
                {
                    var newArr = arr.Skip(1).Select(a => Convert.ToInt32(a)).ToArray();
                    str = Utils.CalculateSumOutPut(str, newArr);
                    Console.WriteLine(str);
                }
                else
                {
                    Console.Write("Error occurs ,you must create a sheet like input 'C 40 4', please enter command again: ", ConsoleColor.Red);
                    continue;
                }
                Console.WriteLine("Press any key continue,press 'q' to  quit !", ConsoleColor.Blue);
                Console.ReadKey();
            }
        }
Пример #6
0
 public void Update(SimpleSheet Sheet)
 {
     db.Entry(Sheet).State = EntityState.Modified;
 }
Пример #7
0
 public void Create(SimpleSheet Sheet)
 {
     db.SimpleSheets.Add(Sheet);
 }