Esempio n. 1
0
 public ActionResult Edit([Bind("ixMaterial,sMaterial,sDescription,ixMaterialType,ixBaseUnit,bTrackSerialNumber,bTrackBatchNumber,bTrackExpiry,nDensity,ixDensityUnit,nShelflife,ixShelflifeUnit,nLength,ixLengthUnit,nWidth,ixWidthUnit,nHeight,ixHeightUnit,nWeight,ixWeightUnit")] MaterialsPost materials)
 {
     if (ModelState.IsValid)
     {
         materials.UserName = User.Identity.Name;
         _materialsService.Edit(materials);
         return(RedirectToAction("Index"));
     }
     //Custom Code Start | Replaced Code Block
     //Replaced Code Block Start
     //ViewBag.ixBaseUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixBaseUnit);
     //ViewBag.ixDensityUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixDensityUnit);
     //ViewBag.ixHeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixHeightUnit);
     //ViewBag.ixLengthUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixLengthUnit);
     //ViewBag.ixMaterialType = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType", materials.ixMaterialType);
     //ViewBag.ixShelflifeUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixShelflifeUnit);
     //ViewBag.ixWeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWeightUnit);
     //ViewBag.ixWidthUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWidthUnit);
     //Replaced Code Block End
     ViewBag.ixBaseUnit      = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementQuantity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixBaseUnit);
     ViewBag.ixHeightUnit    = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixHeightUnit);
     ViewBag.ixLengthUnit    = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixLengthUnit);
     ViewBag.ixDensityUnit   = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementDensity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixDensityUnit);
     ViewBag.ixMaterialType  = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType", materials.ixMaterialType);
     ViewBag.ixShelflifeUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementTime().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixShelflifeUnit);
     ViewBag.ixWeightUnit    = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementWeight().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWeightUnit);
     ViewBag.ixWidthUnit     = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWidthUnit);
     //Custom Code End
     return(View(materials));
 }
Esempio n. 2
0
        public ActionResult Edit(long id)
        {
            MaterialsPost materials = _materialsService.GetPost(id);

            if (materials == null)
            {
                return(NotFound());
            }

            //Custom Code Start | Replaced Code Block
            //Replaced Code Block Start
            //ViewBag.ixBaseUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixBaseUnit);
            //ViewBag.ixDensityUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixDensityUnit);
            //ViewBag.ixHeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixHeightUnit);
            //ViewBag.ixLengthUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixLengthUnit);
            //ViewBag.ixMaterialType = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType", materials.ixMaterialType);
            //ViewBag.ixShelflifeUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixShelflifeUnit);
            //ViewBag.ixWeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWeightUnit);
            //ViewBag.ixWidthUnit = new SelectList(_materialsService.selectUnitsOfMeasurementNullable().Select(x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWidthUnit);
            //Replaced Code Block End
            ViewBag.ixBaseUnit      = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementQuantity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixBaseUnit);
            ViewBag.ixHeightUnit    = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixHeightUnit);
            ViewBag.ixLengthUnit    = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixLengthUnit);
            ViewBag.ixDensityUnit   = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementDensity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixDensityUnit);
            ViewBag.ixMaterialType  = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType", materials.ixMaterialType);
            ViewBag.ixShelflifeUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementTime().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixShelflifeUnit);
            ViewBag.ixWeightUnit    = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementWeight().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWeightUnit);
            ViewBag.ixWidthUnit     = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", materials.ixWidthUnit);
            //Custom Code End



            return(View(materials));
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(long id)
        {
            MaterialsPost materials = _materialsService.GetPost(id);

            materials.UserName = User.Identity.Name;
            _materialsService.Delete(materials);
            return(RedirectToAction("Index"));
        }
        public Task Delete(MaterialsPost materialsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._materialsRepository.RegisterDelete(materialsPost);
            try
            {
                this._materialsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._materialsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.CompletedTask);
        }
        public Task <Int64> Create(MaterialsPost materialsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._materialsRepository.RegisterCreate(materialsPost);
            try
            {
                this._materialsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._materialsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.FromResult(materialsPost.ixMaterial));
        }
Esempio n. 6
0
 public void RegisterDelete(MaterialsPost materialsPost)
 {
     _context.MaterialsPost.Remove(materialsPost);
 }
Esempio n. 7
0
 public void RegisterEdit(MaterialsPost materialsPost)
 {
     _context.Entry(materialsPost).State = EntityState.Modified;
 }
Esempio n. 8
0
 public void RegisterCreate(MaterialsPost materialsPost)
 {
     _context.MaterialsPost.Add(materialsPost);
 }