public ActionResult SavePhoneDevices(AssetModel objModel)
        {
            if (objModel.phonesanddongles.AUOTID == 0)
            {
                PhoneDongle mobile = new PhoneDongle();
                mobile.ModelType    = objModel.phonesanddongles.ModelType;
                mobile.UnitType     = objModel.phonesanddongles.UnitType;
                mobile.AssestNo     = objModel.phonesanddongles.AssestNo;
                mobile.SerialNo     = objModel.phonesanddongles.SerialNo;
                mobile.Provider     = objModel.phonesanddongles.Provider;
                mobile.ConnectionNo = objModel.phonesanddongles.ConnectionNo;
                mobile.SimNo        = objModel.phonesanddongles.SimNo;
                mobile.EMEINo1      = objModel.phonesanddongles.EMEINo1;
                mobile.EMEINo2      = objModel.phonesanddongles.EMEINo2;
                mobile.Remarks      = objModel.phonesanddongles.Remarks;
                mobile.Company      = objModel.company.CompanyID;

                mobile.AddedBy   = "";
                mobile.AddedDate = DateTime.Now;

                _context.PhoneDongles.Add(mobile);
                _context.SaveChanges();

                User _user = _context.Users.Where(w => w.FullName == "IT Pool" && w.Company == objModel.company.CompanyID).FirstOrDefault();

                UnitType _unitType = _context.UnitTypes.Where(w => w.UnitTypeID == mobile.UnitType).FirstOrDefault();

                UserAsset _userAssest = new UserAsset();
                _userAssest.Category = _unitType.Category;
                _userAssest.ItemID   = mobile.AUOTID;
                _userAssest.PANo     = _user.PANo;
                _userAssest.UserID   = _user.UserID;

                _context.UserAssets.Add(_userAssest);
                _context.SaveChanges();
            }
            else
            {
                PhoneDongle mobile = _context.PhoneDongles.Where(m => m.AUOTID == objModel.phonesanddongles.AUOTID).FirstOrDefault();
                mobile.ConnectionNo = objModel.phonesanddongles.ConnectionNo;
                mobile.EMEINo1      = objModel.phonesanddongles.EMEINo1;
                mobile.EMEINo2      = objModel.phonesanddongles.EMEINo2;
                mobile.SimNo        = objModel.phonesanddongles.SimNo;
                mobile.Remarks      = objModel.phonesanddongles.Remarks;
                mobile.Company      = objModel.company.CompanyID;

                mobile.UpdateBy   = "";
                mobile.UpdateDate = DateTime.Now;

                _context.PhoneDongles.Attach(mobile);
                _context.Entry(mobile).State = EntityState.Modified;
                _context.SaveChanges();
            }
            return(RedirectToAction("ViewMobilePhones"));
        }
        public ActionResult ManageMobilePhones(int?id)
        {
            if (id > 0)
            {
                PhoneDongle phones = _context.PhoneDongles.Where(m => m.AUOTID == id).FirstOrDefault();
                if (phones != null)
                {
                    AssetModel objModel = new AssetModel();
                    AssetList  objList  = new AssetList();
                    objList.unittypeList = new List <UnitType>();
                    objList.unittypeList.Add(phones.UnitType1);

                    objList.modelList = new List <ModelType>();
                    objList.modelList.Add(phones.ModelType1);
                    objList.providerList = new List <Provider>();
                    objList.providerList.Add(phones.Provider1);

                    objList.companyList = new List <Company>();
                    objList.companyList.Add(phones.Company1);

                    objModel.assetList        = objList;
                    objModel.phonesanddongles = phones;
                    return(View(objModel));
                }
            }
            else
            {
                AssetModel objModel = new AssetModel();
                AssetList  objList  = new AssetList();
                objModel.phonesanddongles = new PhoneDongle();

                objList.unittypeList = _context.UnitTypes.ToList();
                objList.modelList    = new List <ModelType>();
                objList.providerList = _context.Providers.ToList();
                objList.companyList  = _context.Companies.ToList();

                objModel.assetList = objList;

                return(View(objModel));
            }
            return(null);
        }