RoadSurfaceController.cs 3.18 KB
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using MapsDb;
using MapsDb.Interfaces;
using MapsDb.DataService;
using MapsModels.ViewModels;
using MapsModels.DsModels;
using System;

namespace Maps.Controllers
{
    public class RoadSurfaceController : Controller
    {
        private readonly IRoadDs _roadDs;
        private readonly IRegionDs _regionDs;
        private readonly ISurfaceTypeDs _surfaceTypeDs;
        private readonly IStateCommonDs _stateCommonDs;
        private readonly IRoadSurfaceDs _roadSurfaceDs;
        public RoadSurfaceController(IRoadSurfaceDs RoadSurfaceDs, IStateCommonDs StateCommonDs, IRoadDs RoadDs, IRegionDs RegionDs, ISurfaceTypeDs SurfaceTypeDs)
        {
            _roadDs = RoadDs;    
            _surfaceTypeDs = SurfaceTypeDs;    
            _regionDs = RegionDs;    
            _stateCommonDs = StateCommonDs;     
            _roadSurfaceDs = RoadSurfaceDs;     
        }

        // GET: BusStop
        [HttpGet]
        public async Task<IActionResult> Index([FromQuery] PaginationDsM data)
        {
            var Data = await _roadSurfaceDs.GetIndexListAsync(data);

            RoadSurfaceListVm vm = new RoadSurfaceListVm
            {
                RoadSurfaceEditDsM = Data.ToList()
            };

            return Json(vm);
        }

        //[HttpGet]
        // public async Task<IActionResult> Directory(){
        //     var DepartmentAffiliation = await _departmentAffiliationDs.GetSelectListAsync();
        //     var Settlement = await _settlementDs.GetSelectListAsync();
        //     var Road = await _roadDs.GetSelectListAsync();
        //     var Region = await _regionDs.GetSelectListAsync();
        //     var ServiceObjectType = await _serviceObjectTypeDs.GetSelectListAsync();
        //     CatalogListVm vm = new CatalogListVm
        //     {
        //         DepartmentAffiliationSelectListDsM = DepartmentAffiliation.ToList(),
        //         SettlementSelectListDsM = Settlement.ToList(),
        //         ServiceObjectTypeSelectListDsM = ServiceObjectType.ToList(),
        //         RoadSelectListDsM = Road.ToList(),
        //         RegionSelectListDsM = Region.ToList()
        //     };
        //     return Json(vm);
        // }


        // [HttpPost]
        // public async Task<IActionResult> Create([FromBody] ServiceObjectEditDsM data)
        // {
        //     var result = await _serviceObjectDs.CreateAsync(data);
        //     return Json(result);
        // }

        // [HttpPost]
        // public async Task<IActionResult> Update(int id, [FromBody] ServiceObjectEditDsM data){
        //         await _serviceObjectDs.UpdateAsync(data,id);
        //         return Json(String.Empty);
        // }

     
        // [HttpDelete]
        // public async Task<IActionResult> Delete(int id)
        // {   
        //     try
        //     {
        //          int data = await _serviceObjectDs.DeleteAsync(id);
        //          return Json(data);
        //     }
        //     catch (ArgumentNullException )
        //     {
        //         return NotFound();
        //     }
        // }
    }
}