示例#1
0
        public async Task <ResultModel> UpdateVehicle(int id, [FromBody] Vehicle vehicle)
        {
            try
            {
                bool response = await _vehicleRepository.UpdateVehicleAsync(id, vehicle);

                return(ResponceModel.GetUpdatedResponse(response, id));
            }
            catch (Exception ex)
            {
                var st = new StackTrace();
                return(ResponceModel.GetExceptionResponse(ex, st.GetFrame(0).GetMethod().DeclaringType.FullName));
            }
        }
示例#2
0
        public async Task <ResultModel> AddVehicle([FromBody] Vehicle vehicle)
        {
            try
            {
                int response = await _vehicleRepository.AddVehicleAsync(vehicle);

                return(ResponceModel.GetSavedResponse(response > 0, response));
            }
            catch (Exception ex)
            {
                var st = new StackTrace();
                return(ResponceModel.GetExceptionResponse(ex, st.GetFrame(0).GetMethod().DeclaringType.FullName));
            }
        }
示例#3
0
        public async Task <ResultModel> GetVehicles()
        {
            try
            {
                var data = await _vehicleRepository.GetVehiclesAsync();

                return(ResponceModel.GetResponse(data));
            }
            catch (Exception ex)
            {
                var st = new StackTrace();
                return(ResponceModel.GetExceptionResponse(ex, st.GetFrame(0).GetMethod().DeclaringType.FullName));
            }
        }
示例#4
0
        public async Task <ResultModel> SearchVehicles(Vehicle vehicle, int PageSize = 10, int PageNo = 1)
        {
            try
            {
                var data = await _vehicleRepository.GetSearchVehiclesAsync(PageSize, PageNo, vehicle);

                return(ResponceModel.GetResponse(data));
            }
            catch (Exception ex)
            {
                var st = new StackTrace();
                return(ResponceModel.GetExceptionResponse(ex, st.GetFrame(0).GetMethod().DeclaringType.FullName));
            }
        }
示例#5
0
        public async Task <ResultModel> UploadProfileImage(int id, [FromForm] IFormFile file)
        {
            try
            {
                string fName      = file.FileName;
                string imagesPath = @"ProfileImages/" + file.FileName;
                string path       = Path.Combine(_environment.ContentRootPath, imagesPath);

                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await file.CopyToAsync(stream);
                }

                bool response = await _userRepository.UploadProfileImageAsync(id, imagesPath);

                return(ResponceModel.GetUpdatedResponse(response, id));
            }
            catch (Exception ex)
            {
                var st = new StackTrace();
                return(ResponceModel.GetExceptionResponse(ex, st.GetFrame(0).GetMethod().DeclaringType.FullName));
            }
        }