Ejemplo n.º 1
0
        //public string UniqueDetailsAssets(AssetDetailsFileIdModel assetDetailsModel)
        //{
        //    using (var context = new INVENTORYEntities())
        //    {
        //        AssetID assetID = new AssetID();
        //        assetID.emp_id = assetDetailsModel._EmpId;
        //        assetID.assetid1 = assetDetailsModel._AssetId;//unique asset id add to ASSETID TABLE
        //      //  byte[] uploadedFile = new byte[assetDetailsModel.UploadAgreement.InputStream.Length];
        //      //  assetDetailsModel.UploadAgreement.InputStream.Read(uploadedFile, 0, uploadedFile.Length);
        //      //  assetID.ContentType = uploadedFile;//FILE UPLOAD AS VARBINARY MAX IN ASSSETID TABLE
        //        //string fileName = Path.GetFileName(assetDetailsModel.UploadAgreement.FileName);
        //        //assetID.filename1 = fileName;//FILE NAME IN ASSETID TABLE
        //        //string fullpath = "~/Agreement_Files/";
        //        //assetDetailsModel.FullPath = fullpath + fileName;
        //        //assetID.filePath = assetDetailsModel.FullPath;//FULL PATH ADD IN ASSETID TABLE
        //        context.AssetID.Add(assetID);//ADD TO TABLE
        //        context.SaveChanges();//SAVE CHANGES IN TABLE
        //        return assetID.emp_id;
        //    }
        //}

        public string AddNewAsset(AssetDetailsModel assetDetailsModel)
        {
            using (var context = new INVENTORYEntities())
            {
                AssetDetails assetNameKey = new AssetDetails();
                assetNameKey.emp_id = assetDetailsModel.EmpId;
                //assetNameKey.asset_id = assetDetailsModel.AssetId;
                assetNameKey.asset_id_sub = assetDetailsModel.AssetId_unique;

                assetNameKey.asset_name = assetDetailsModel.AssetName;

                assetNameKey.serial_no   = assetDetailsModel.SerialNo;
                assetNameKey.ip_address  = assetDetailsModel.IpAddress;
                assetNameKey.mac_address = assetDetailsModel.MacAddress;
                assetNameKey.Processor   = assetDetailsModel.Processor;

                assetNameKey.hdd            = assetDetailsModel.HDD;
                assetNameKey.ram            = assetDetailsModel.RAM;
                assetNameKey.warranty_start = assetDetailsModel.WarrantyStart;
                assetNameKey.warranty_end   = assetDetailsModel.WarrantyEnd;
                assetNameKey.Dateofissue    = assetDetailsModel.DateOfIssue;

                context.AssetDetails.Add(assetNameKey);
                context.SaveChanges();
                return(assetNameKey.emp_id);
            }
        }
Ejemplo n.º 2
0
        public JsonResult AddNewAssetDetails(AssetDetailsModel assetDetailsModel)
        {
            string message = "";
            string Emp_id  = "";

            if (ModelState.IsValid)
            {
                var isExist            = AssetAlreadyExist(assetDetailsModel.AssetId_unique);
                var SerialExist        = AssetAlreadyExist(assetDetailsModel.SerialNo);
                var CheckEmployeeExist = Employee_Exist(assetDetailsModel.EmpId);

                if (isExist == false || SerialExist == false)
                {
                    message = "Asset Already Exist";
                }
                else if (CheckEmployeeExist == true)
                {
                    message = "Employee Not Exist in GMDA !!";
                }

                else if (isExist == true || SerialExist == true)
                {
                    Emp_id = repositories.AddNewAsset(assetDetailsModel);
                    if (Emp_id != null)
                    {
                        ModelState.Clear();
                        message = "Asset Added Successfully";
                        //return Json(new { message=message},JsonRequestBehavior.AllowGet);
                    }
                }
            }
            return(Json(new { message = message, Emp_id = Emp_id }, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> Save(AssetDetailsModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var repo = new AssetRepository();
            var id   = await repo.SaveAssetAsync(new Asset { Id = model.Id, Name = model.Name, Width = model.Width, Height = model.Height, Length = model.Length, GroupId = model.GroupId });

            return(RedirectToAction("View", new { assetId = id }));
        }
        public IActionResult Details(int id)
        {
            var item = _ILibraryAsset.GetById(id);

            if (item == null)
            {
                return(NotFound());
            }
            var model = new AssetDetailsModel {
                Id       = item.Id,
                Cost     = item.Cost,
                ImageUrl = item.ImageUrl,
                Title    = item.Title,
                Year     = item.Year,
                status   = item.Status.Name
            };

            model.checkOutHistory = GetAllById(id);
            return(View(model));
        }