// Edit Asset
        public ActionResult Edit(int?id)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("HomePage", "Home"));
            }

            ViewBag.orglist = generalCategoryManager.GetAll();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Asset asset = assetManager.GetById(id);

            if (asset == null)
            {
                return(HttpNotFound());
            }
            bool s = Request.QueryString["Update"] == "true";

            if (s)
            {
                ViewData["Update"] = "Update Successfully";
            }
            return(View(asset));
        }
        // GET: Assets/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Asset asset = _assetManager.GetById((long)id);

            if (asset == null)
            {
                return(HttpNotFound());
            }
            return(View(asset));
        }
        public ActionResult Create(AssetRegistrationCreateVM model)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("HomePage", "Home"));
            }


            string format = "d";

            model.RegistrationDate = DateTime.Today.ToString(format);

            var assetRegistration = Mapper.Map <AssetRegistration>(model);

            bool isSaved = assetRegistrationManager.Add(assetRegistration);

            foreach (var a in assetRegistration.AssetRegistrationDetailses)
            {
                Asset asset = new Asset();
                asset            = assetManager.GetById(a.AssetId);
                asset.Registered = true;
                assetManager.Update(asset);
            }

            if (isSaved)
            {
                ModelState.Clear();
                ViewBag.message = "Save Successfully";
                //return RedirectToAction("Create");
            }



            model.AssetLookUp  = loader.GetUpdateAssetSelectListItems();
            model.BranchLookUp = loader.GetBrandSelectListItems();

            model.RegisteredBy = Session["username"].ToString();
            if (Session["username"].ToString() == "Organization Owner" || Session["designation"].ToString() == "Manager")
            {
                int orgid = 0;
                var list  = userManager.GetAll().Where(c => c.UserName == Session["username"].ToString() && c.Designation == Session["designation"].ToString());
                foreach (var t in list)
                {
                    orgid = t.OrganizationId;
                }
                ViewBag.orglist = organizationManager.GetAll().Where(c => c.Id == orgid);
            }
            else
            {
                ViewBag.orglist = organizationManager.GetAll();
            }


            return(View(model));
        }