Example #1
0
        public static Salaryadjustment GetObject(Salaryadjustment o, FormCollection fc)
        {
            string staff_id = fc.Get("staff_id");

            string paramInc = fc.Get("inc");
            double inc      = CommonHelper.GetValue <double>(paramInc);

            string paramMonth = fc.Get("month");
            int    month      = CommonHelper.GetValue <int>(paramMonth);

            string paramYear = fc.Get("year");
            int    year      = CommonHelper.GetValue <int>(paramYear);

            if (o == null)
            {
                o = new Salaryadjustment();
            }

            o.Staffid = staff_id;
            o.Inc     = inc;
            o.Month   = month;
            o.Year    = year;

            return(o);
        }
        public async Task <JsonResult> Create(FormCollection fc)
        {
            Salaryadjustment o = SalaryadjustmentHelper.GetObject(null, fc);

            Dictionary <string, object> err = null;

            ISession se = NHibernateHelper.CurrentSession;

            err = o.IsValid();

            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", "Salary Adjustment was successfully added." }
                },
                            JsonRequestBehavior.AllowGet));
            }

            else
            {
                return(Json(err, JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <ActionResult> Edit(Guid id)
        {
            ViewBag.form_id = "edit-form";

            ISession         se = NHibernateHelper.CurrentSession;
            Salaryadjustment o  = await Task.Run(() => { return(se.Get <Salaryadjustment>(id)); });

            return(View("_form", o));
        }
Example #4
0
        private static async Task CreateSalaryAdj(ISession se, string staffId)
        {
            Random r = new Random();

            await Task.Run(() =>
            {
                for (int y = 2001; y <= DateTime.Now.Year; y++)
                {
                    int x = r.Next(50, 90);
                    Salaryadjustment o = new Salaryadjustment {
                        Staffid = staffId, Inc = x, Month = 1, Year = y
                    };
                    se.SaveOrUpdate(o);
                }
            });
        }