예제 #1
0
        public async Task <IHttpActionResult> UpdateAsync(int luotTruyCapId, [FromBody] LuotTruyCap luotTruyCap)
        {
            if (luotTruyCap.LuotTruyCapId != luotTruyCapId)
            {
                return(BadRequest("Id mismatch"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            using (var db = new ApplicationDbContext())
            {
                bool exists = db.LuotTruyCap.Count(o => o.LuotTruyCapId == luotTruyCapId) > 0;
                if (!exists)
                {
                    return(NotFound());
                }
                db.Entry(luotTruyCap).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(Ok(luotTruyCap));
            }
        }
예제 #2
0
        protected void Session_Start()
        {
            Application.Lock();
            Application["VisitorOnline"] = (int)Application["VisitorOnline"] + 1;
            LuotTruyCap luotTruyCap = new LuotTruyCap();

            luotTruyCap.IP                  = Request.UserHostAddress;
            luotTruyCap.ThietBi             = Request.UserAgent;
            luotTruyCap.ThoiGian            = DateTime.Now;
            luotTruyCap.TrangTruyCapDauTien = Request.Url.OriginalString.Length > 250? Request.Url.OriginalString.Substring(0, 250):  Request.Url.OriginalString;
            luotTruyCapService.ThemLuotTruyCap(luotTruyCap);
            Application.UnLock();
        }
예제 #3
0
        public async Task <IHttpActionResult> InsertAsync([FromBody] LuotTruyCap luotTruyCap)
        {
            if (luotTruyCap.LuotTruyCapId != 0)
            {
                return(BadRequest("Invalid LuotTruyCapId"));
            }

            using (var db = new ApplicationDbContext())
            {
                db.LuotTruyCap.Add(luotTruyCap);
                await db.SaveChangesAsync();
            }

            return(Ok(luotTruyCap));
        }
예제 #4
0
        protected void Session_Start(object sender, EventArgs e)
        {
            thuctaptotnghiepDbContext db = new thuctaptotnghiepDbContext();
            var allow = db.LuotTruyCaps.FirstOrDefault();

            if (allow == null)
            {
                allow       = new LuotTruyCap();
                allow.today = 0;
                allow.total = 0;
                db.LuotTruyCaps.Add(allow);
            }
            if (allow.datetoday == null)
            {
                allow.datetoday = DateTime.Now;
                if (allow.today == null)
                {
                    allow.today  = 1;
                    allow.total += 1;
                }
                else
                {
                    allow.today += 1;
                    allow.total += 1;
                }
            }
            else if (allow.datetoday.Value.Date == DateTime.Now.Date)
            {
                allow.today += 1;
                allow.total += 1;
            }
            else
            {
                allow.datetoday = DateTime.Now;
                allow.today     = 1;
                allow.total    += 1;
            }
            db.SaveChanges();
        }
예제 #5
0
        public void today()
        {
            var allow = db.LuotTruyCaps.FirstOrDefault();

            if (allow == null)
            {
                allow       = new LuotTruyCap();
                allow.today = 0;
                allow.total = 0;
                db.LuotTruyCaps.Add(allow);
            }
            if (allow.datetoday == null)
            {
                allow.datetoday = DateTime.Now;
                if (allow.today == null)
                {
                    allow.today  = 1;
                    allow.total += 1;
                }
                else
                {
                    allow.today += 1;
                    allow.total += 1;
                }
            }
            else if (allow.datetoday.Value.Date == DateTime.Now.Date)
            {
                allow.today += 1;
                allow.total += 1;
            }
            else
            {
                allow.datetoday = DateTime.Now;
                allow.today     = 1;
                allow.total    += 1;
            }
            db.SaveChanges();
        }