Exemplo n.º 1
0
        private void Checkin(FaceIDEntities db, int class_id, string code, double latitude, double longitude, string email, double accuracy)
        {
            var model = db.CheckIns.SingleOrDefault(c => c.Class_id == class_id && c.Code == code);

            if (model == null)
            {
                model = new CheckIn
                {
                    date      = DateTime.Now,
                    Class_id  = class_id,
                    Code      = code,
                    Latitude  = latitude,
                    Longitude = longitude,
                    Email     = email,
                    Accuracy  = accuracy
                };
                db.CheckIns.Add(model);
            }
            else
            {
                model.date            = DateTime.Now;
                model.Latitude        = model.Latitude;
                model.Longitude       = model.Longitude;
                model.Email           = email;
                model.Accuracy        = model.Accuracy;
                db.Entry(model).State = EntityState.Modified;
            }
        }
        public async Task <ActionResult> Edit([Bind(Include = "id,Code,Error,Trace")] ErrorLog errorLog)
        {
            if (ModelState.IsValid)
            {
                db.Entry(errorLog).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(errorLog));
        }