Exemplo n.º 1
0
        //GET: AssetTypes/Create
        public ActionResult Create()
        {
            List <String> listAssetType = _assetTypeService.GetAll().Select(at => at.Name).ToList();

            ViewBag.listAssetType = listAssetType;
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult ImportAsset(string assetType)
        {
            //Session["current"] = assetType;
            SelectList cateList = new SelectList(assetTypeService.GetAll().Where(a => a.Active), "Name", "Name");

            ViewBag.listTypeSearch = cateList;

            return(View());
        }
Exemplo n.º 3
0
        public ActionResult ReadTypes([DataSourceRequest] DataSourceRequest dRequest)
        {
            var types = AssetTypeService.GetAll();
            DataSourceResult result = new DataSourceResult()
            {
                Data  = types,
                Total = types.Count
            };

            return(Json(result));
        }
Exemplo n.º 4
0
        // GET: PIC
        public ActionResult Index(int page = 1)
        {
            int pageSize = int.Parse(ConfigHelper.GetKey("PageSize"));

            int totalRow = 0;

            var PICsModel = _PICService.GetAllPaging(out totalRow, page, pageSize, new string[] { "Area", "ApplicationUser", "AssetType" });

            int totalPage = (int)Math.Ceiling((double)totalRow / pageSize);

            var PICViewModel = Mapper.Map <IEnumerable <PIC>, IEnumerable <PICViewModel> >(PICsModel);

            var locationModel = _locationService.GetAll();

            ViewBag.locationViewModel = Mapper.Map <IEnumerable <Location>, IEnumerable <LocationViewModel> >(locationModel);

            var assetTypeModel = _assetTypeService.GetAll();

            ViewBag.assetTypeViewModel = Mapper.Map <IEnumerable <AssetType>, IEnumerable <AssetTypeViewModel> >(assetTypeModel);

            var paginationSet = new PaginationSet <PICViewModel>()
            {
                Items      = PICViewModel,
                MaxPage    = int.Parse(ConfigHelper.GetKey("MaxSize")),
                Page       = page,
                TotalCount = totalRow,
                TotalPages = totalPage
            };

            ViewBag.query = new
            {
                page = page
            };
            return(View(paginationSet));
        }
Exemplo n.º 5
0
        public ActionResult Create(AssetViewModel assetViewModel, int?idArea, int SelectedOption)
        {
            var validateMail = _assetService.GetAll(new string[] { "Area", "Area.Location" }).FirstOrDefault
                                   (x => x.Name == assetViewModel.Name && x.Area.ID == assetViewModel.AreaID && x.ID != assetViewModel.ID);

            if (validateMail != null)
            {
                ModelState.AddModelError("Name", "Name already exists in Area");
            }

            var    listAttribute = _assetAttributeService.GetAssetAttributes(assetViewModel.AssetTypeID);
            string assetTypeCode = "";

            assetTypeCode = _assetService.GetStringAssetCode(SelectedOption);
            if (listAttribute.Count() > 0)
            {
                if (ModelState.IsValid)
                {
                    assetViewModel.Active    = true;
                    assetViewModel.CreatedAt = DateTime.Now;
                    assetViewModel.UpdatedAt = DateTime.Now;
                    assetViewModel.AssetCode = assetTypeCode;
                    TempData["idArea"]       = idArea;
                    return(RedirectToAction("CreateAttributeValue", assetViewModel));
                }
                var areas      = _areaService.GetAll();
                var assetTypes = _assetTypeService.GetAll();
                ViewBag.AreaID      = new SelectList(areas, "ID", "AreaCode");
                ViewBag.AssetTypeID = new SelectList(assetTypes, "ID", "Name");
                return(View(assetViewModel));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    Asset asset = new Asset()
                    {
                        AssetTypeID       = assetViewModel.AssetTypeID,
                        AreaID            = assetViewModel.AreaID,
                        Name              = assetViewModel.Name,
                        AssetCode         = assetTypeCode,
                        StartDate         = assetViewModel.StartDate,
                        Quantity          = assetViewModel.Quantity,
                        Description       = assetViewModel.Description,
                        ApplicationUserID = Convert.ToInt32(User.Identity.GetUserId()),
                        Active            = true,
                        CreatedAt         = DateTime.Now,
                        UpdatedAt         = DateTime.Now,
                    };
                    var checkAdd = _assetService.Add(asset, new List <AssetAttributeValue>());
                    if (checkAdd)
                    {
                        SetAlert("Add Asset success", "success");
                    }
                    else
                    {
                        SetAlert("Add Asset error", "error");
                    }
                    if (idArea != null)
                    {
                        return(RedirectToAction("AssetArea", "Asset", new { id = idArea }));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                var areas      = _areaService.GetAll();
                var assetTypes = _assetTypeService.GetAll();
                ViewBag.AreaID      = new SelectList(areas, "ID", "AreaCode");
                ViewBag.AssetTypeID = new SelectList(assetTypes, "ID", "Name");
                return(View(assetViewModel));
            }
        }