public async Task <ActionResult> Vendors()
        {
            var model = new Device_Vendor();

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

            ViewBag.DevicesBrands = Device_Vendor;
            return(View(model));
        }
        public async Task <JsonResult> AddUpdateVendors(Device_Vendor obj)
        {
            if (obj.Id == 0)
            {
                var exsist = _db.Device_Vendors.FirstOrDefault(x => x.Name == obj.Name);
                if (exsist != null)
                {
                    return(Json("exists", JsonRequestBehavior.AllowGet));
                }
                var model = new Device_Vendor();
                model.Name        = obj.Name;
                model.Address     = obj.Address;
                model.Description = obj.Description;
                model.IsActive    = obj.IsActive.GetInteger();
                model.PhoneNumber = obj.PhoneNumber;
                model.CreatedDate = DateTime.Now;
                model.CreatedBy   = User.Identity.GetUserId();
                _db.Device_Vendors.Add(model);
                var save = await _db.SaveChangesAsync();

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

                model.Name        = obj.Name;
                model.Address     = obj.Address;
                model.Description = obj.Description;
                model.IsActive    = obj.IsActive.GetInteger();
                model.PhoneNumber = obj.PhoneNumber;

                model.ModifiedBy = User.Identity.GetUserId();

                model.ModifiedDate     = DateTime.Now;
                _db.Entry(model).State = EntityState.Modified;
                var save = await _db.SaveChangesAsync();

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