Exemplo n.º 1
0
        public async Task <JsonResult> Create(FormCollection fc)
        {
            Overtimerate o = OvertimerateHelper.GetObject(null, fc);

            Dictionary <string, object> err = null;

            ISession se = NHibernateHelper.CurrentSession;

            err = o.IsValid(se);

            if (err == null)
            {
                await Task.Run(() =>
                {
                    using (ITransaction tx = se.BeginTransaction())
                    {
                        se.SaveOrUpdate(o);
                        tx.Commit();
                    }
                });

                return(Json(new Dictionary <string, object>
                {
                    { "success", 1 },
                    { "message", "Overtime Rate  was successfully added." }
                },
                            JsonRequestBehavior.AllowGet));
            }

            else
            {
                return(Json(err, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> List()
        {
            int    year       = CommonHelper.GetValue <int>(Request["year"], 0);
            int    pgnum      = CommonHelper.GetValue <int>(Request["pgnum"], 1);
            int    pgsize     = CommonHelper.GetValue <int>(Request["pgsize"], 0);
            string sortcolumn = CommonHelper.GetValue(Request["sortcolumn"], OvertimerateHelper.DEFAULT_SORT_COLUMN);
            string sortdir    = CommonHelper.GetValue(Request["sortdir"], OvertimerateHelper.DEFAULT_SORT_DIR);

            Sort sort = new Sort(sortcolumn, sortdir);

            Dictionary <string, object> filters = new Dictionary <string, object>
            {
                { "year", year }
            };

            ListModel <Overtimerate> l = null;

            if (year == 0)
            {
                l = await OvertimerateHelper.GetAll(pgnum, pgsize, sort);
            }

            else
            {
                l = await OvertimerateHelper.GetFilterBy(filters, pgnum, pgsize, sort);
            }

            return(View("_list", l));
        }
Exemplo n.º 3
0
        //
        // GET: /Admin/OvertimeRate/

        public async Task <ActionResult> Index()
        {
            ListModel <Overtimerate> l = null;

            l = await OvertimerateHelper.GetAll();

            return(View(l));
        }
Exemplo n.º 4
0
        public async Task <JsonResult> Delete(FormCollection fc)
        {
            int    year   = CommonHelper.GetValue <int>(Request["year"], 0);
            int    pgnum  = CommonHelper.GetValue <int>(Request["pgnum"], 1);
            int    pgsize = CommonHelper.GetValue <int>(Request["pgsize"], 0);
            string ids    = fc.Get("id[]");

            string[] idlist = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            string itemscount = null;

            Dictionary <string, object> filters = new Dictionary <string, object>
            {
                { "year", year }
            };

            ISession se = NHibernateHelper.CurrentSession;

            await Task.Run(() =>
            {
                using (ITransaction tx = se.BeginTransaction())
                {
                    se.CreateQuery("delete from Overtimerate where id in (:idlist)")
                    .SetParameterList("idlist", idlist)
                    .ExecuteUpdate();
                    tx.Commit();
                }
            });

            if (year == 0)
            {
                itemscount = await OvertimerateHelper.GetItemMessage(null, pgnum, pgsize);
            }

            else
            {
                itemscount = await OvertimerateHelper.GetItemMessage(filters, pgnum, pgsize);
            }

            return(Json(new Dictionary <string, object>
            {
                { "success", 1 },
                { "itemscount", itemscount },
                { "message", string.Format("{0} Overtime rate(s) was successfully deleted.", idlist.Length) }
            },
                        JsonRequestBehavior.AllowGet));
        }