Exemple #1
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // Stores the Request in an Accessible object
            var request = filterContext.HttpContext.Request;
            // Generate an audit
            Audit audit = new Audit()
            {
                // Your Audit Identifier
                AuditID = Guid.NewGuid(),
                // Our Username (if available)
                UserName = (request.IsAuthenticated) ? filterContext.HttpContext.User.Identity.Name : "Anonymous",
                // The IP Address of the Request
                IPAddress = request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? request.UserHostAddress,
                // The URL that was accessed
                URLAccessed = request.RawUrl,
                // Creates our Timestamp
                TimeAccessed = DateTime.UtcNow,
                Data         = SerializeRequest(request)
            };

            // Stores the Audit in the Database
            QLNSContext context = new QLNSContext();

            context.Audit.Add(audit);
            context.SaveChanges();

            // Finishes executing the Action as normal
            base.OnActionExecuting(filterContext);
        }
Exemple #2
0
        public static void Init(QLNSContext context)
        {
            var AccountAdminName = "admin";
            var admin            = context.Users.Where(x => x.UserName == AccountAdminName).FirstOrDefault();

            if (admin != null)
            {
                var listOperation = context.Operation.ToList();
            }
        }
Exemple #3
0
        public static void Init(QLNSContext context)
        {
            var DanTocGroup = context.DM_NhomDanhmuc.Where(x => x.GroupCode == DanhMucConstantBase.DanToc).FirstOrDefault();

            if (DanTocGroup == null)
            {
                context.DM_NhomDanhmuc.Add(new DM_NhomDanhmuc()
                {
                    GroupCode = DanhMucConstantBase.DanToc,
                    GroupName = DanhMucConstantBase.DanToc
                });
                context.SaveChanges();
            }
        }
 public ChucVuController(QLNSContext db)
 {
     database = db;
 }
Exemple #5
0
 public LuongController(QLNSContext db, IWebHostEnvironment hostEnvironment)
 {
     database             = db;
     this.hostEnvironment = hostEnvironment;
 }
Exemple #6
0
        // GET: KhenThuongController
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            //A ViewBag property provides the view with the current sort order, because this must be included in
            //  the paging links in order to keep the sort order the same while paging
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            ViewBag.Role = TempData["Role"];

            var ModelList = new List <KhenThuong>();

            //ViewBag.CurrentFilter, provides the view with the current filter string.
            //he search string is changed when a value is entered in the text box and the submit button is pressed. In that case, the searchString parameter is not null.
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;


            using (var context = new QLNSContext())
            {
                var modelv = from s in context.KhenThuongs
                             select s;
                //Search and match data, if search string is not null or empty
                if (!String.IsNullOrEmpty(searchString))
                {
                    modelv = modelv.Where(s => s.Idkt.ToString().Contains(searchString) ||
                                          s.IdnvNavigation.TenNv.Contains(searchString) ||
                                          s.IdloaiKtNavigation.TenKt.Contains(searchString) ||
                                          s.Ngay.Value.Month.ToString().Contains(searchString));
                }
                switch (sortOrder)
                {
                case "name_desc":
                    ModelList = modelv.OrderByDescending(s => s.Idkt).ToList();
                    break;

                default:
                    ModelList = modelv.OrderBy(s => s.Idkt).ToList();
                    break;
                }
            }
            //indicates the size of list
            int pageSize = 5;
            //set page to one is there is no value, ??  is called the null-coalescing operator.
            int pageNumber = (page ?? 1);
            //return the Model data with paged

            var model = new ViewModelDG();

            model.ListNhanVien       = database.NhanViens.ToArray();
            model.ListKhenThuongs    = ModelList.ToPagedList(pageNumber, pageSize);
            model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray();
            return(View(model));
        }
Exemple #7
0
 public HopDongLaoDongController(QLNSContext db)
 {
     database = db;
 }
 public PhongBanController(QLNSContext db)
 {
     database = db;
 }
 public EmployeeController(QLNSContext dbContext, IJsReportMVCService jsReportMVCService)
 {
     _dbContext         = dbContext;
     _empRepo           = new EmpRepository();
     JsReportMVCService = jsReportMVCService;
 }
 public AccountController(QLNSContext context)
 {
     _context = context;
 }