public async Task<HttpResponseMessage> GetWorkflow(Int32 id)
        {
            var response = new SingleModelResponse<WorkflowViewModel>() as ISingleModelResponse<WorkflowViewModel>;

            try
            {
                var model = await Task.Run(() =>
                {
                    return BusinessObject.GetWorkflow(new Workflow { ID = id });
                });

                response.Model = new WorkflowViewModel(model);
            }
            catch (Exception ex)
            {
                response.DidError = true;
                response.ErrorMessage = ex.Message;
            }

            return response.ToHttpResponse(Request);
        }
        public async Task<HttpResponseMessage> CreateWorkflow([FromBody]WorkflowViewModel value)
        {
            var response = new SingleModelResponse<WorkflowViewModel>() as ISingleModelResponse<WorkflowViewModel>;

            try
            {
                var model = await Task.Run(() =>
                {
                    return BusinessObject.AddWorkflow(value.ToEntity());
                });

                response.Model = new WorkflowViewModel(model);
            }
            catch (Exception ex)
            {
                response.DidError = true;
                response.ErrorMessage = ex.Message;
            }

            return response.ToHttpResponse(Request);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> DeleteProduct(Int32 id)
        {
            var response = new SingleModelResponse <ProductViewModel>() as ISingleModelResponse <ProductViewModel>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(AdventureWorksRepository.DeleteProduct(id));
                });

                response.Model   = entity.ToViewModel();
                response.Message = "The record was deleted successfully";
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> DeleteOrderStatusAsync(Int32 id)
        {
            var response = new SingleModelResponse <OrderStatusViewModel>() as ISingleModelResponse <OrderStatusViewModel>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(_RESTfulAPI_Repository.DeleteOrderStatus(id));
                });

                response.Model = entity.ToViewModel();
                response.Info  = "The record was deleted successfully";
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> CreateProduct([FromBody] ProductViewModel value)
        {
            var response = new SingleModelResponse <ProductViewModel>() as ISingleModelResponse <ProductViewModel>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(AdventureWorksRepository.AddProduct(value.ToEntity()));
                });

                response.Model   = entity.ToViewModel();
                response.Message = "The data was saved successfully";
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.ToString();
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Update(int id, PartnerContactResource resource)
        {
            var response = new SingleModelResponse <PartnerContactResource>();

            if (resource == null)
            {
                response.DidError     = true;
                response.ErrorMessage = ResponseMessageConstants.NotFound;
                return(response.ToHttpResponse());
            }
            try
            {
                var entity = await _repository.FindAsync(x => x.Id == id);

                if (entity == null)
                {
                    response.DidError     = true;
                    response.ErrorMessage = ResponseMessageConstants.NotFound;
                    return(response.ToHttpResponse());
                }

                _mapper.Map(resource, entity);

                await _repository.UpdateAsync(entity);

                response.Model   = _mapper.Map(entity, resource);
                response.Message = ResponseMessageConstants.Success;
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.ToString();
                _logger.LogInformation(ex.Message);
                _logger.LogTrace(ex.InnerException.ToString());
            }

            return(response.ToHttpResponse());
        }
        public async Task <HttpResponseMessage> UpdateProduct(Int32 id, [FromBody] Product value)
        {
            var response = new SingleModelResponse <Product>() as ISingleModelResponse <Product>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(BusinessObject.UpdateProduct(value));
                });

                response.Model = entity;
            }
            catch (Exception ex)
            {
                ExceptionHelper.Publish(ex);

                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse(Request));
        }
Ejemplo n.º 8
0
        public async Task <ISingleModelResponse <string> > Refresh(int instanceId)
        {
            ISingleModelResponse <string> result = new SingleModelResponse <string>();

            result.ErrorMessage = "OK";

            try
            {
                ChannelFactory <IWCFContract> mChannelFacory = new ChannelFactory <IWCFContract>(new NetTcpBinding(),
                                                                                                 new EndpointAddress(ENDPOINT));
                IWCFContract proxy = mChannelFacory.CreateChannel();

                proxy.RefreshInstance(instanceId);
            }
            catch (Exception e)
            {
                result.DidError     = true;
                result.ErrorMessage = e.Message;
            }


            return(result);
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> UpdateAthlete([FromBody] Athlete athlete)
        {
            var response = new SingleModelResponse <Athlete>()
                           as ISingleModelResponse <Athlete>;

            try
            {
                if (athlete == null)
                {
                    throw new Exception("Model is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    return(_context.UpdateAthlete(athlete));
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> ForgotPassword([FromBody] string email)
        {
            var response = new SingleModelResponse <Athlete>()
                           as ISingleModelResponse <Athlete>;

            try
            {
                if (email == null)
                {
                    throw new Exception("Email Address is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    return(_context.ForgotPassword(email));
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
        public async Task <HttpResponseMessage> GetCategory(Int32 id)
        {
            var response = new SingleModelResponse <CategoryViewModel>() as ISingleModelResponse <CategoryViewModel>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(BusinessObject.GetCategory(new Category(id)));
                });

                response.Model = new CategoryViewModel(entity);
            }
            catch (Exception ex)
            {
                ExceptionHelper.Publish(ex);

                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse(Request));
        }
        public async Task <HttpResponseMessage> DeleteSupplier(Int32 id)
        {
            var response = new SingleModelResponse <Supplier>() as ISingleModelResponse <Supplier>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(BusinessObject.DeleteSupplier(new Supplier(id)));
                });

                response.Model = entity;
            }
            catch (Exception ex)
            {
                ExceptionHelper.Publish(ex);

                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse(Request));
        }
Ejemplo n.º 13
0
        public SingleModelResponse <TModel> DeleteContent <TModel>(string requestUri, int content)
            where TModel : class
        {
            using (httpClient = new HttpClient())
            {
                SingleModelResponse <TModel> model = null;
                httpClient.BaseAddress = new Uri(BaseUri);
                httpClient.DefaultRequestHeaders.Accept.Clear();
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");

                var response = httpClient.PutAsync(requestUri, new StringContent(JsonConvert.SerializeObject(content), System.Text.Encoding.UTF8, "application/json"))
                               .ContinueWith((taskwithresponse) =>
                {
                    var resp = taskwithresponse.Result.Content.ReadAsStringAsync();
                    resp.Wait();
                    model = JsonConvert.DeserializeObject <SingleModelResponse <TModel> >(resp.Result);
                }
                                             );
                response.Wait();
                return(model);
            }
        }
        public async Task <HttpResponseMessage> CreateRegion([FromBody] Region value)
        {
            var response = new SingleModelResponse <Region>() as ISingleModelResponse <Region>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(BusinessObject.CreateRegion(value));
                });

                response.Model = entity;
            }
            catch (Exception ex)
            {
                ExceptionHelper.Publish(ex);

                response.ErrorMessage = ex.Message;
                response.DidError     = true;
            }

            return(response.ToHttpResponse(Request));
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> GetCreateOrderRequestAsync()
        {
            Logger?.LogInformation("{0} has been invoked", nameof(GetCreateOrderRequestAsync));

            var response = new SingleModelResponse <CreateOrderViewModel>() as ISingleModelResponse <CreateOrderViewModel>;

            var customersResponse = await SalesBusinessObject.GetCustomersAsync();

            response.Model.Customers = customersResponse.Model.Select(item => new CustomerViewModel(item));

            var employeesResponse = await HumanResourcesBusinessObject.GetEmployeesAsync();

            response.Model.Employees = employeesResponse.Model.Select(item => new EmployeeViewModel(item));

            var shippersResponse = await SalesBusinessObject.GetShippersAsync();

            response.Model.Shippers = shippersResponse.Model.Select(item => new ShipperViewModel(item));

            var productsResponse = await ProductionBusinessObject.GetProductsAsync();

            response.Model.Products = productsResponse.Model.Select(item => new ProductViewModel(item));

            return(response.ToHttpResponse());
        }
Ejemplo n.º 16
0
        public async Task <ISingleModelResponse <Order> > RemoveOrderAsync(Int32 id)
        {
            Logger?.LogInformation("{0} has been invoked", nameof(RemoveOrderAsync));

            var response = new SingleModelResponse <Order>();

            try
            {
                response.Model = await SalesRepository.GetOrderAsync(new Order(id));

                if (response.Model?.OrderDetails.Count > 0)
                {
                    throw new ForeignKeyDependencyException(
                              String.Format("Order with ID: {0} cannot be deleted, because has dependencies. Please contact to technical support for more details", id)
                              );
                }
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response);
        }
Ejemplo n.º 17
0
        public IActionResult Update([FromBody] ProductViewModel productVm)
        {
            var response = new SingleModelResponse <ProductViewModel>() as ISingleModelResponse <ProductViewModel>;

            try
            {
                var dbProduct = _productService.GetById(productVm.ID);
                dbProduct.UpdateProduct(productVm);

                _productService.Update(dbProduct);
                _productService.Save();

                var responseData = Mapper.Map <ProductViewModel>(dbProduct);
                response.Model   = responseData;
                response.Message = dbProduct.Name + " đã được cập nhật thành công";
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.ToString();
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> UpdateRun([FromBody] Run run)
        {
            var response = new SingleModelResponse <Run>()
                           as ISingleModelResponse <Run>;

            try
            {
                if (run == null)
                {
                    throw new Exception("Run is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    Run runn = _context.UpdateRun(run);
                    return(runn);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> UpdateOrderAsync(Int32 id, [FromBody] OrderViewModel value)
        {
            var response = new SingleModelResponse <OrderViewModel>() as ISingleModelResponse <OrderViewModel>;

            try
            {
                var entity = await Task.Run(() =>
                {
                    return(_RESTfulAPI_Repository.UpdateOrder(id, value.ToEntity()));
                });



                response.Model = entity.ToViewModel();
                response.Info  = "The record was updated successfully";
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> Update(int id, AreaResource resource)
        {
            var response = new SingleModelResponse <AreaResource>();

            if (resource == null)
            {
                response.DidError     = true;
                response.ErrorMessage = "Input cannot be null.";
                return(response.ToHttpResponse());
            }
            try
            {
                var area = await _areaRepository.FindAsync(x => x.Id == id);

                if (area == null || resource == null)
                {
                    response.DidError     = true;
                    response.ErrorMessage = "Input could not be found.";
                    return(response.ToHttpResponse());
                }

                _mapper.Map(resource, area);

                await _areaRepository.UpdateAsync(area);

                response.Model   = _mapper.Map(area, resource);
                response.Message = "The data was saved successfully";
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.ToString();
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 21
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> EditRoute([FromBody] Route route)
        {
            var response = new SingleModelResponse <Route>()
                           as ISingleModelResponse <Route>;

            try
            {
                if (route == null)
                {
                    throw new Exception("Route Model is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    Route uproute = _context.UpdateRoute(route);
                    return(uproute);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> UpdateClub([FromBody] Club club)
        {
            var response = new SingleModelResponse <Club>()
                           as ISingleModelResponse <Club>;

            try
            {
                if (club == null)
                {
                    throw new Exception("Model is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    Club cl = _context.UpdateClub(club);
                    return(cl);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 23
0
        public async Task <ISingleModelResponse <Order> > CreateOrderAsync(Order header, OrderDetail[] details)
        {
            Logger?.LogInformation("{0} has been invoked", nameof(CreateOrderAsync));

            var response = new SingleModelResponse <Order>();

            try
            {
                using (var transaction = await DbContext.Database.BeginTransactionAsync())
                {
                    var warehouses = await ProductionRepository.GetWarehouses().ToListAsync();

                    try
                    {
                        foreach (var detail in details)
                        {
                            var product = await ProductionRepository.GetProductAsync(new Product { ProductID = detail.ProductID });

                            if (product == null)
                            {
                                throw new NonExistingProductException(
                                          String.Format("Sent order has a non existing product with ID: '{0}', order has been cancelled.", detail.ProductID)
                                          );
                            }
                            else
                            {
                                detail.ProductName = product.ProductName;
                            }

                            if (product.Discontinued == true)
                            {
                                throw new AddOrderWithDiscontinuedProductException(
                                          String.Format("Product with ID: '{0}' is discontinued, order has been cancelled.", product.ProductID)
                                          );
                            }

                            detail.UnitPrice = product.UnitPrice;
                            detail.Total     = product.UnitPrice * detail.Quantity;
                        }

                        header.Total = details.Sum(item => item.Total);

                        await SalesRepository.AddOrderAsync(header);

                        foreach (var detail in details)
                        {
                            detail.OrderID = header.OrderID;

                            await SalesRepository.AddOrderDetailAsync(detail);

                            var lastInventory = ProductionRepository
                                                .GetProductInventories()
                                                .Where(item => item.ProductID == detail.ProductID)
                                                .OrderByDescending(item => item.CreationDateTime)
                                                .FirstOrDefault();

                            var stocks = lastInventory == null ? 0 : lastInventory.Stocks - detail.Quantity;

                            var productInventory = new ProductInventory
                            {
                                ProductID        = detail.ProductID,
                                WarehouseID      = warehouses.First().WarehouseID,
                                CreationDateTime = DateTime.Now,
                                Quantity         = detail.Quantity * -1,
                                Stocks           = stocks
                            };

                            await ProductionRepository.AddProductInventoryAsync(productInventory);
                        }

                        response.Model = header;

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();

                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response);
        }
Ejemplo n.º 24
0
        public SingleModelResponse<EventViewModel> GetEvent(int eventId)
        {
            string getUrl = EventUri + "GetEvent?eventId="+eventId;
            var evnt = GetSingleContent<Event>(getUrl);
            List<EventRouteViewModel> routes = new List<EventRouteViewModel>();
            if (evnt.Model.EventRoute.Count>0)
            {
                foreach (EventRoute rou in evnt.Model.EventRoute)
                {
                    EventRouteViewModel newRoute = new EventRouteViewModel
                    {
                        Title = rou.Title,
                        DateAdded = rou.DateAdded,
                        RouteId = rou.RouteID,
                        EventRouteId = rou.EventRouteID,
                        DateModified = rou.DateAdded,
                        Distance = rou.Distance,
                        Description = rou.Description,
                        EventId = rou.EventID
                    };
                    routes.Add(newRoute);
                }
            }
            EventViewModel ConvertedEvent = new EventViewModel
            {
                EventId = evnt.Model.EventId,
                Date = evnt.Model.Date,
                DateCreated = evnt.Model.DateCreated,
                DateModified = evnt.Model.DateModified,
                Description = evnt.Model.Description,
                UserID = evnt.Model.UserID,
                Location = evnt.Model.Location,
                Time = evnt.Model.Time,
                Title = evnt.Model.Title,
                EventRoutes = routes,

            };
            if(evnt.Model.ClubID>0)
            {
                ConvertedEvent.ClubId = evnt.Model.ClubID;
                ConvertedEvent.ClubName = evnt.Model.Club.Name;
            }
            SingleModelResponse<EventViewModel> model = new SingleModelResponse<EventViewModel>
            {
                DidError = evnt.DidError,
                Message = evnt.Message,
                ErrorMessage = evnt.ErrorMessage,
                Model = ConvertedEvent
            };
            return model;
        }
Ejemplo n.º 25
0
        public virtual ActionResult Details(int id)
        {
            var viewModel = new AdministratorViewModel <DetailsViewModel>();
            var response  = new SingleModelResponse <DetailsViewModel>
            {
                IsValid = true,
            };

            if (id == 0)
            {
                response = _helpService.SetNewView();

                viewModel.Data         = response.Model;
                viewModel.Descriptions = this.FillMultiLanguageBoxSimpleModel(
                    "description", response.Model.Descriptions);
                viewModel.Urls = this.FillMultiLanguageBoxSimpleModel(
                    "url", response.Model.Urls, new bool[] { true, false, false, false });

                viewModel.ButtonConfiguration = new ButtonControlViewModel
                {
                    ActionEdit = "edit",
                    ActionSave = "saveDetails",

                    HasEditButton = IDBContext.Current.HasPermission(
                        Permission.HELP_CONVERGENCE_WRITE),

                    NavigationCancel = Url.Action(
                        controllerName: "Help",
                        actionName: "Index"),
                    UrlSave = Url.Action(
                        controllerName: "Help",
                        actionName: "SaveViewHelpData")
                };

                return(View(viewModel));
            }

            response = _helpService.GetViewData(id);

            if (!response.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            viewModel.Data         = response.Model;
            viewModel.Descriptions = this.FillMultiLanguageBoxSimpleModel(
                "description", response.Model.Descriptions);
            viewModel.Urls = this.FillMultiLanguageBoxSimpleModel(
                "url", response.Model.Urls, new bool[] { true, false, false, false });

            viewModel.ButtonConfiguration = new ButtonControlViewModel
            {
                ActionCancel = "cancelDetails",
                ActionEdit   = "edit",
                ActionSave   = "saveDetails",

                HasEditButton = IDBContext.Current.HasPermission(
                    Permission.HELP_CONVERGENCE_WRITE),

                UrlSave = Url.Action(
                    controllerName: "Help",
                    actionName: "SaveViewHelpData")
            };

            return(View(viewModel));
        }
Ejemplo n.º 26
0
        public IActionResult PutUserData([FromBody] User user)
        {
            var response = new SingleModelResponse <UserListVM>() as ISingleModelResponse <UserListVM>;
            var result   = new UserListVM();

            try
            {
                if (ModelState.IsValid)
                {
                    var details = _userService.GetUserById(user.userid);
                    if (details == null)
                    {
                        response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        response.Success    = "N";
                        response.Message    = "Data does not exists.";
                    }
                    else
                    {
                        details.branchid        = user.branchid;
                        details.name            = user.name;
                        details.email           = user.email;
                        details.telno           = user.telno;
                        details.address         = user.address;
                        details.username        = user.username;
                        details.password        = user.password;
                        details.lastupdateddate = user.lastupdateddate;
                        details.lastupdatedby   = user.lastupdatedby;
                        details.nactive         = user.nactive;
                        details.usertypeid      = user.usertypeid;

                        var IsSuccess = _userService.UpdateUserData(details);
                        if (IsSuccess)
                        {
                            result = _userService.GetUserListsById(details.userid);
                        }

                        else
                        {
                            result = null;
                        }

                        response.StatusCode = (int)HttpStatusCode.OK;
                        response.Success    = "Y";
                        response.Message    = "Save data successful.";
                        response.Data       = result;
                    }
                }
                else
                {
                    response.StatusCode = (int)HttpStatusCode.InternalServerError;
                    response.Success    = "N";
                    response.Message    = "Invalid entry.";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = (int)HttpStatusCode.InternalServerError;
                response.Success    = "N";
                response.Message    = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> ImportEmployees()
        {
            ISingleModelResponse <dynamic> response = new SingleModelResponse <dynamic>();

            try
            {
                var file = Request.Form.Files[0];
                using (var stream = file.OpenReadStream())
                {
                    using (var reader = new StreamReader(stream))
                    {
                        reader.ReadLine();

                        IList <Employee>   employees   = new List <Employee>();
                        IList <Department> departments = _departmentRepository.GetDepartments().Result;
                        _logger.LogInformation(entities.LoggingEvents.ImportEmployee, null, "line from Employees: {0}", departments);
                        while (!reader.EndOfStream)
                        {
                            string line = reader.ReadLine();
                            _logger.LogInformation(entities.LoggingEvents.ImportEmployee, null, "lines from Employees: {0}", line);
                            string[] columns = line.Split(",");
                            if (columns.Count() == 5)
                            {
                                Employee employee = new Employee();
                                if (!String.IsNullOrEmpty(columns[0]))
                                {
                                    employee.FirstName = columns[0];
                                }

                                if (!String.IsNullOrEmpty(columns[1]))
                                {
                                    employee.LastName = columns[1];
                                }

                                employee.Cell  = columns[2];
                                employee.Email = columns[3];

                                // if (!String.IsNullOrEmpty(columns[4]))
                                // {
                                //     var department = departments.Where(x => x.Code == columns[4]).SingleOrDefault();
                                //     employee.Department = new DropDownValue() { _id = department.Id, Name = department.Name };
                                // }

                                employees.Add(employee);
                            }

                            await _employeeRepository.AddEmployees(employees);

                            response.IsError = false;
                            response.Model   = new { TotalCount = employees.Count, SuccessCount = 10 };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.IsError = true;
                response.Message = "Could not import Employees, Please check again";
                return(BadRequest("Upload Failed: " + ex.Message));
            }
            return(Ok(response));
        }