Ejemplo n.º 1
0
        public IActionResult Index(string id)
        {
            Tool tools = _toolService.GetByToolName(id);
            //Console.WriteLine(tools.toolName);
            List <History> historys = _historyService.GetByToolName(tools.toolName);

            if (tools != null)
            {
                dynamic mymodel = new ExpandoObject();
                mymodel.tools = tools;
                List <History> temp   = historys.OrderBy(history => history.rentTime).ToList();
                List <History> result = new List <History>();
                result.Add(new History
                {
                    rentTime = DateTime.Now.Date
                });
                foreach (var item in temp)
                {
                    if (item.lendTime == item.createTime && DateTime.Compare(item.rentTime.Date, DateTime.Now.Date) <= 0)
                    {
                        result.Add(item);
                    }
                }
                mymodel.historys = result;
                //Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
                return(View(mymodel));
            }
            return(View("ไม่มีอุปกรณ์"));
        }
Ejemplo n.º 2
0
        public IActionResult PlusCount(string toolName)
        {
            Tool tool = _toolService.GetByToolName(toolName);

            // Console.WriteLine(JsonConvert.SerializeObject(tool, Formatting.Indented));
            tool.maxCount += 1;
            _toolService.Update(tool.id, tool);
            return(RedirectToAction("RoomAndTool", new { roomName = tool.room }));
        }