public async Task <ActionResult> DeviceTypeIndex()
        {
            var model       = new RPMService();
            var devicetypes = await _db.RPMServices.ToListAsync();

            ViewBag.devicetypes = devicetypes;
            return(View(model));
        }
        public async Task <ActionResult> Service()
        {
            var model = new RPMService();

            ViewBag.IsAvtiveStatus = Enum.GetValues(typeof(IsActiveStatus)).Cast <IsActiveStatus>().Select(y => new SelectListItem {
                Text = y.ToString(), Value = ((int)y).ToString()
            }).ToList();
            var devicetypes = await _db.RPMServices.ToListAsync();

            ViewBag.devicetypes = devicetypes;
            return(View(model));
        }
        public async Task <ActionResult> DeviceTypeDetails(int?id)

        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RPMService devicetype = await _db.RPMServices.FindAsync(id);

            if (devicetype == null)
            {
                return(HttpNotFound());
            }
            return(View(devicetype));
        }
        public async Task <JsonResult> DeviceTypeCreate(RPMService obj)
        {
            if (obj.Id == 0)
            {
                var model = new RPMService();
                model.ServiceName         = obj.ServiceName;
                model.IsActive            = obj.IsActive;
                model.ReasonForDeactivate = obj.ReasonForDeactivate;
                if (Session["UserID"] != null)
                {
                    model.CreatedBy  = Session["UserID"].ToString();
                    model.ModifiedBy = Session["UserID"].ToString();
                }
                model.CreatedDate  = DateTime.Now;
                model.ModifiedDate = DateTime.Now;
                _db.RPMServices.Add(model);
                var save = await _db.SaveChangesAsync();

                if (save > 0)
                {
                    return(Json("added", JsonRequestBehavior.AllowGet));
                }
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
            else
            {
                var device = await _db.RPMServices.FirstOrDefaultAsync(x => x.Id == obj.Id);

                device.ServiceName         = obj.ServiceName;
                device.IsActive            = obj.IsActive;
                device.ReasonForDeactivate = obj.ReasonForDeactivate;
                if (Session["UserID"] != null)
                {
                    device.ModifiedBy = Session["UserID"].ToString();
                }
                device.ModifiedDate     = DateTime.Now;
                _db.Entry(device).State = EntityState.Modified;
                var save = await _db.SaveChangesAsync();

                if (save > 0)
                {
                    return(Json("updated", JsonRequestBehavior.AllowGet));
                }
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }