Exemple #1
0
        public IActionResult CreateRoomRecords([FromRoute] string location, [FromRoute] int start, [FromRoute] int end, [FromRoute] int capacity, [FromRoute] string prefix)
        {
            if (prefix == "NN")
            {
                prefix = "";
            }

            StringBuilder str = new StringBuilder();

            for (int i = start; i <= end; i++)
            {
                string rn = prefix + i.ToString();
                if (_context.Room.Where(m => m.Location == location && m.RoomName == rn).Count() > 0)
                {
                    str.Append(rn + " ");
                    continue;
                }
                Room room = new Room();
                room.Location = location;
                room.RoomName = rn;
                room.Capacity = capacity;
                room.Status   = 0;
                _context.Add(room);
                _context.SaveChanges();
            }
            return(Content("Done -- " + str));
        }
Exemple #2
0
        public static void Log(ferrousContext dbContext, HttpContext httpContext, string message, int level, bool no_save = false)
        {
            var entry = new LogEntry();

            entry.Timestamp = DateTime.Now;
            entry.username  = httpContext.User.Identity.Name;
            entry.message   = message;
            entry.level     = level;
            dbContext.Add(entry);
            if (!no_save)
            {
                dbContext.SaveChanges();
            }
        }