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")); }
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)); }
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(); } }