Beispiel #1
0
        public ActionResult IPASave(IPAViewModel ipaVM)
        {
            db = new VirsagiContext();

            var ipa = new IPA
            {
                IPAID        = ipaVM.IPAID,
                PassportNo   = ipaVM.PassportNo,
                WorkerName   = ipaVM.WorkerName,
                Employer     = ipaVM.Employer,
                WorkPermitNo = ipaVM.WorkPermitNo,
                ReferenceNo  = ipaVM.ReferenceNo,
                IssuanceDate = ipaVM.IssuanceDate
            };

            if (ipaVM.IPAID == 0)
            {
                db.IPAs.Add(ipa);
                db.SaveChanges();
            }
            else
            {
                db.IPAs.Add(ipa);
                db.Entry(ipa).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("IPA"));
        }
Beispiel #2
0
        public ActionResult EditNews(News news)
        {
            db = new VirsagiContext();

            news.LastUpdatedBy = DateTime.Now;
            db.News.Add(news);
            db.Entry(news).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(View(news));
        }
Beispiel #3
0
        private void AddHitCount()
        {
            using (VirsagiContext db = new VirsagiContext())
            {
                var hitCounter = db.HitCounters.FirstOrDefault();
                hitCounter.TotalCount++;
                hitCounter.MonthlyCount++;

                if (DateTime.Now.Day == 1)
                {
                    hitCounter.MonthlyCount = 1;
                }

                db.HitCounters.Add(hitCounter);
                db.Entry(hitCounter).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
        }