Esempio n. 1
0
        public ActionResult Create(loggers d)
        {
            if (ModelState.IsValid)
            {
                using (var northwind = new hercules_dbEntities())
                {
                    //Get max ID table loggers
                    var crum = northwind.loggers.Max(sd => sd.ID);

                    int current_id = Convert.ToInt32(crum.ToString());

                    // Create a new Product entity and set its properties from the posted ProductViewModel
                    var entity = new loggers
                    {

                        ID = current_id + 1,
                        LoggerSMSNumber = d.LoggerSMSNumber,
                        LoggerSerialNumber = d.LoggerSerialNumber,
                        Notes = d.Notes,
                        CreationDate = DateTime.Now,
                        Adress = d.Adress,
                        LatEast = d.LatEast,
                        LongNorth = d.LongNorth,
                        HeightAOD = d.HeightAOD,
                        LoggerTypeClass = d.LoggerTypeClass,
                        SiteID = d.SiteID,
                        OwnerAccount = Convert.ToInt16(Session["LogedUserID"].ToString()),
                        CompanyID = Convert.ToInt16(Session["CompanyID"].ToString()),
                        LoggerStatus = true

                    };
                    // Add the entity
                    northwind.loggers.Add(entity);
                    // Insert the entity in the database
                    northwind.SaveChanges();
                    // Get the ProductID generated by the database

                }

                return RedirectToAction("ListLogger");
                // return View();

            }
            else
            {
                return View();
            }
        }
Esempio n. 2
0
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request,loggers log)
        {
            using (var db = new hercules_dbEntities())
            {
                   var result = from u in db.loggers where (u.ID == log.ID) select u;
                    if (result.Count() != 0)
                    {
                        var dbuser = result.First();
                        dbuser.LoggerStatus = false;

                        db.SaveChanges();
                    }
            }

            return Json(new[] { log }.ToDataSourceResult(request, ModelState));
        }
Esempio n. 3
0
        public ActionResult Edit([DataSourceRequest] DataSourceRequest request, loggers us)
        {
            if (ModelState.IsValid)
            {
                using (var db = new hercules_dbEntities())
                {
                    var result = from u in db.loggers where (u.ID == us.ID) select u;
                    if (result.Count() != 0)
                    {
                        var dblogger = result.First();

                        dblogger.LoggerSMSNumber = us.LoggerSMSNumber;
                        dblogger.LoggerSerialNumber = us.LoggerSerialNumber;
                        dblogger.Notes = us.Notes;
                        dblogger.Adress = us.Adress;
                        dblogger.LatEast = us.LatEast;
                        dblogger.LongNorth = us.LongNorth;
                        dblogger.HeightAOD = us.HeightAOD;
                        dblogger.LoggerTypeClass = us.LoggerTypeClass;
                        if(us.SiteID != null)
                        dblogger.SiteID = us.SiteID;

                        db.SaveChanges();
                    }
                }
            }

            return RedirectToAction("ListLogger");
        }