public IActionResult Create(AddressCreateViewModel vm)
        {
            string userId     = _userManager.GetUserId(User);
            int    customerId = _customerDataService.GetQuery().Include(c => c.Addresses).Where(c => c.UserID == userId).Select(c => c.CustomerId).FirstOrDefault();

            //check if data is valid
            if (ModelState.IsValid)
            {
                //map to vm
                Address address = new Address
                {
                    StreetNumber = vm.StreetNumber,
                    StreetName   = vm.StreetName,
                    City         = vm.City,
                    State        = vm.State,
                    Postcode     = vm.Postcode,
                    Country      = vm.Country,
                    CustomerId   = customerId
                };

                //call service
                _addressDataService.Create(address);
                TempData["message"] = $"New address successfully saved.";

                //return to home
                return(RedirectToAction("Display", "Address"));
            }

            //if invalid
            return(View(vm));
        }
Exemplo n.º 2
0
        public IActionResult Create(string returnUrl = "/Account/Profile")
        {
            AddressCreateViewModel vm = new AddressCreateViewModel {
                ReturnUrl = returnUrl
            };

            return(View(vm));
        }
Exemplo n.º 3
0
        public IActionResult Create()
        {
            var      userID = _userManagerService.GetUserId(User);
            Customer cust   = _customerService.GetQuery(c => c.UserId == userID);
            IEnumerable <Address> addList = _addressService.GetAll();

            AddressCreateViewModel vm = new AddressCreateViewModel
            {
                CustomerId = cust.CustomerId
            };

            return(View(vm));
        }
Exemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public async Task CreateByViewModelAsync(AddressCreateViewModel viewModel)
        {
            // Check
            if (viewModel == null)
            {
                throw new ArgumentException(nameof(viewModel));
            }

            // Process
            var address = _mapper.Map <Address>(viewModel);

            _addressStore.Add(address);
            await _unitOfWork.SaveAllChangesAsync(auditUserId : _httpContextManager.CurrentUserId());
        }
Exemplo n.º 5
0
 public IActionResult EditAddress(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         var address = _db.AddressesGenericRepository.GetById(id);
         var model   = new AddressCreateViewModel
         {
             City        = address.City,
             FullAddress = address.FullAddress,
             PhoneNumber = address.PhoneNumber,
             PostAddress = address.PostAddress,
             Title       = address.Title,
             Id          = address.Id
         };
         return(View(model));
     }
     return(RedirectToAction(nameof(Addresses)));
 }
Exemplo n.º 6
0
 public IActionResult EditAddress(AddressCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         var address = _db.AddressesGenericRepository.GetById(model.Id);
         address.City        = model.City;
         address.FullAddress = model.FullAddress;
         address.PhoneNumber = model.PhoneNumber;
         address.PostAddress = model.PostAddress;
         address.Title       = model.Title;
         address.Id          = model.Id;
         _db.AddressesGenericRepository.Update(address);
         _db.Save();
         return(RedirectToAction(nameof(Addresses)));
     }
     else
     {
         return(View(model));
     }
 }
Exemplo n.º 7
0
        public IActionResult Create(AddressCreateViewModel vm)
        {
            var      userID   = _userManagerService.GetUserId(User);
            Customer customer = _customerService.GetQuery(c => c.UserId == userID);

            if (ModelState.IsValid)
            {
                Address add = new Address
                {
                    HouseAddress = vm.HouseAddress,
                    Suburb       = vm.Suburb,
                    State        = vm.State,
                    Postcode     = vm.Postcode,
                    CustomerId   = vm.CustomerId
                };
                _addressService.Create(add);

                return(RedirectToAction("Index", "Home"));
            }
            return(View(vm));
        }
Exemplo n.º 8
0
        public IActionResult Create(AddressCreateViewModel vm)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = _userManager.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();

                Address a = new Address
                {
                    City         = vm.City,
                    PostCode     = vm.PostCode,
                    State        = vm.State,
                    StreetName   = vm.StreetName,
                    StreetNumber = vm.StreetNumber,
                    Suburb       = vm.Suburb,
                    UnitNumber   = vm.UnitNumber,
                    CustomerId   = user.Id
                };
                _addressDataservice.Add(a);
                return(Redirect(vm.ReturnUrl));
            }
            return(View(vm));
        }
Exemplo n.º 9
0
 public IActionResult AddAddress(AddressCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         var address = new Address
         {
             City        = model.City,
             FullAddress = model.FullAddress,
             IsDeleted   = false,
             PhoneNumber = model.PhoneNumber,
             PostAddress = model.PostAddress,
             Title       = model.Title,
             UserId      = User.FindFirst(ClaimTypes.NameIdentifier).Value
         };
         _db.AddressesGenericRepository.Insert(address);
         _db.Save();
         return(RedirectToAction(nameof(Addresses)));
     }
     else
     {
         return(View(model));
     }
 }
Exemplo n.º 10
0
        public async Task <IHttpActionResult> Createaddress()
        {
            ResponseDataDTO <address> response = new ResponseDataDTO <address>();

            try
            {
                var path = Path.GetTempPath();

                if (!Request.Content.IsMimeMultipartContent("form-data"))
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
                }

                MultipartFormDataStreamProvider streamProvider = new MultipartFormDataStreamProvider(path);

                await Request.Content.ReadAsMultipartAsync(streamProvider);

                //Các trường bắt buộc
                if (streamProvider.FormData["add_province"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Tinh/Thành phố không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["add_district"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Quan/Huyen phố không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["add_ward"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Phuong/Xa phố không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["staff_id"] == null && streamProvider.FormData["customer_id"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Phuong/Xa phố không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                AddressCreateViewModel addressCreateViewModel = new AddressCreateViewModel
                {
                    add_province = Convert.ToString(streamProvider.FormData["add_province"]),

                    add_district = Convert.ToString(streamProvider.FormData["add_district"]),
                    add_ward     = Convert.ToString(streamProvider.FormData["add_ward"]),
                };
                if (streamProvider.FormData["staff_id"] == null)
                {
                    addressCreateViewModel.staff_id = null;
                }
                else
                {
                    addressCreateViewModel.staff_id = Convert.ToInt32(streamProvider.FormData["staff_id"]);
                }
                if (streamProvider.FormData["customer_id"] == null)
                {
                    addressCreateViewModel.customer_id = null;
                }
                else
                {
                    addressCreateViewModel.customer_id = Convert.ToInt32(streamProvider.FormData["customer_id"]);
                }

                var createAddress = _mapper.Map <address>(addressCreateViewModel);
                _addressservice.Create(createAddress);
                // return response
                response.Code    = HttpCode.OK;
                response.Message = MessageResponse.SUCCESS;
                response.Data    = createAddress;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                response.Message = ex.Message;
                response.Data    = null;
                Console.WriteLine(ex.ToString());

                return(Ok(response));
            }
        }
Exemplo n.º 11
0
        public async Task <IHttpActionResult> Createstaff()
        {
            ResponseDataDTO <staff> response = new ResponseDataDTO <staff>();

            try
            {
                var path = Path.GetTempPath();

                if (!Request.Content.IsMimeMultipartContent("form-data"))
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
                }

                MultipartFormDataStreamProvider streamProvider = new MultipartFormDataStreamProvider(path);

                await Request.Content.ReadAsMultipartAsync(streamProvider);

                // save file
                string fileName = "";
                foreach (MultipartFileData fileData in streamProvider.FileData)
                {
                    fileName = (FileExtension.SaveFileOnDisk(fileData));
                }
                #region ["Check null"]

                if (streamProvider.FormData["sta_fullname"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Họ và tên không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["sta_username"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Tên đăng nhập không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["sta_password"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Mật khẩu không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }

                if (streamProvider.FormData["sta_mobile"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Số điện thoại không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }

                if (streamProvider.FormData["sta_status"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Trạng thái không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }

                if (streamProvider.FormData["department_id"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Phòng ban không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }


                if (streamProvider.FormData["position_id"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Chức vụ không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["add_province"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Tinh/Thanh pho không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["add_district"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Quan/Huyen không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["add_ward"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Xa/Phuong không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                #endregion

                #region ["Check exits"]
                if (!check_department(Convert.ToInt32(streamProvider.FormData["department_id"])))
                {
                    response.Code    = HttpCode.NOT_FOUND;
                    response.Message = "Khong co ma phong ban trong csdl!";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (!check_position(Convert.ToInt32(Convert.ToInt32(streamProvider.FormData["position_id"]))))
                {
                    response.Code    = HttpCode.NOT_FOUND;
                    response.Message = "Khong co ma bo phan trong csdl!";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (!check_grouprole(Convert.ToInt32(streamProvider.FormData["group_role_id"])))
                {
                    response.Code    = HttpCode.NOT_FOUND;
                    response.Message = "Khong co ma nhom quyen trong csdl!";
                    response.Data    = null;
                    return(Ok(response));
                }

                #endregion
                // get data from formdata những trường bắt buộc
                StaffCreateViewModel StaffCreateViewModel = new StaffCreateViewModel
                {
                    sta_fullname = Convert.ToString(streamProvider.FormData["sta_fullname"]),
                    //sta_code = Convert.ToString(streamProvider.FormData["sta_code"]),
                    sta_username = Convert.ToString(streamProvider.FormData["sta_username"]),
                    sta_password = Convert.ToString(streamProvider.FormData["sta_password"]),
                    sta_email    = Convert.ToString(streamProvider.FormData["sta_email"]),

                    sta_aboutme            = Convert.ToString(streamProvider.FormData["sta_aboutme"]),
                    sta_mobile             = Convert.ToString(streamProvider.FormData["sta_mobile"]),
                    sta_identity_card      = Convert.ToString(streamProvider.FormData["sta_identity_card"]),
                    sta_address            = Convert.ToString(streamProvider.FormData["sta_address"]),
                    sta_hometown           = Convert.ToString(streamProvider.FormData["sta_hometown"]),
                    sta_reason_to_end_work = Convert.ToString(streamProvider.FormData["sta_reason_to_end_work"]),
                    sta_note = Convert.ToString(streamProvider.FormData["sta_note"]),

                    department_id   = Convert.ToInt32(streamProvider.FormData["department_id"]),
                    group_role_id   = Convert.ToInt32(streamProvider.FormData["group_role_id"]),
                    social_id       = Convert.ToInt32(streamProvider.FormData["social_id"]),
                    position_id     = Convert.ToInt32(streamProvider.FormData["position_id"]),
                    sta_leader_flag = Convert.ToByte(streamProvider.FormData["sta_leader_flag"]),



                    sta_status = Convert.ToByte(streamProvider.FormData["sta_status"]),
                    sta_sex    = Convert.ToByte(streamProvider.FormData["sta_sex"]),
                };
                //Kiểm tra các trường rằng buộc
                if (check_username_email(StaffCreateViewModel.sta_username, StaffCreateViewModel.sta_email))
                {
                    response.Code    = HttpCode.NOT_FOUND;
                    response.Message = "Da co username '" + StaffCreateViewModel.sta_username + "' hoac email '" + StaffCreateViewModel.sta_email + "' trong csdl";
                    response.Data    = null;
                    return(Ok(response));
                }
                //md5
                if (StaffCreateViewModel.sta_email != null)
                {
                    if (CheckEmail.IsValidEmail(StaffCreateViewModel.sta_email) == false)
                    {
                        response.Message = "Định dạng email không hợp lệ !";
                        response.Data    = null;
                        return(Ok(response));
                    }
                }

                //check_phone_number

                if (CheckNumber.IsPhoneNumber(StaffCreateViewModel.sta_mobile) == false)
                {
                    response.Message = "Số điện thoại không hợp lệ";
                    response.Data    = null;
                    return(Ok(response));
                }
                //Bắt các truongf còn lại
                //check datetime

                if (streamProvider.FormData["sta_birthday"] == null)
                {
                    StaffCreateViewModel.sta_birthday = null;
                }
                else
                {
                    StaffCreateViewModel.sta_birthday = Convert.ToDateTime(streamProvider.FormData["sta_birthday"]);
                }

                if (streamProvider.FormData["sta_identity_card_date"] == null)
                {
                    StaffCreateViewModel.sta_identity_card_date = null;
                }
                else
                {
                    StaffCreateViewModel.sta_identity_card_date = Convert.ToDateTime(streamProvider.FormData["sta_identity_card_date"]);
                }
                if (streamProvider.FormData["sta_end_work_date"] == null)
                {
                    StaffCreateViewModel.sta_end_work_date = null;
                }
                else
                {
                    StaffCreateViewModel.sta_end_work_date = Convert.ToDateTime(streamProvider.FormData["sta_end_work_date"]);
                }
                if (streamProvider.FormData["sta_start_work_date"] == null)
                {
                    StaffCreateViewModel.sta_start_work_date = null;
                }
                else
                {
                    StaffCreateViewModel.sta_start_work_date = Convert.ToDateTime(streamProvider.FormData["sta_start_work_date"]);
                }


                if (streamProvider.FormData["sta_created_date"] == null)
                {
                    StaffCreateViewModel.sta_created_date = DateTime.Now;
                }
                //Lấy ra bản ghi cuối cùng tạo mã code
                var x = _staffservice.GetLast();

                StaffCreateViewModel.sta_code = Utilis.CreateCode("KH", x.sta_id, 7);
                // mapping view model to entity
                var createdstaff = _mapper.Map <staff>(StaffCreateViewModel);
                createdstaff.sta_thumbnai = fileName;
                createdstaff.sta_password = StaffCreateViewModel.sta_password;

                // save new staff
                _staffservice.Create(createdstaff);
                var get_last_id = _staffservice.GetLast();
                //Create address
                AddressCreateViewModel addressCreateViewModel = new AddressCreateViewModel
                {
                    add_province = Convert.ToString(streamProvider.FormData["add_province"]),

                    add_district = Convert.ToString(streamProvider.FormData["add_district"]),
                    add_ward     = Convert.ToString(streamProvider.FormData["add_ward"]),
                };
                addressCreateViewModel.staff_id = get_last_id.sta_id;
                var createAddress = _mapper.Map <address>(addressCreateViewModel);
                _addressService.Create(createAddress);

                // return response
                response.Code    = HttpCode.OK;
                response.Message = MessageResponse.SUCCESS;
                response.Data    = createdstaff;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                response.Message = ex.Message;
                response.Data    = null;

                return(Ok(response));
            }
        }
Exemplo n.º 12
0
        public async Task <IHttpActionResult> Createcustomer()
        {
            ResponseDataDTO <customer> response = new ResponseDataDTO <customer>();

            try
            {
                var path = Path.GetTempPath();

                if (!Request.Content.IsMimeMultipartContent("form-data"))
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
                }

                MultipartFormDataStreamProvider streamProvider = new MultipartFormDataStreamProvider(path);

                await Request.Content.ReadAsMultipartAsync(streamProvider);

                // save file
                string fileName = "";
                foreach (MultipartFileData fileData in streamProvider.FileData)
                {
                    fileName = (FileExtension.SaveFileOnDisk(fileData));
                }
                //Cach truong bat buoc
                if (streamProvider.FormData["cu_fullname"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Họ và tên không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["cu_mobile"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Số điện thoại không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["cu_email"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Email không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["cu_type"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Loại khách hàng không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["customer_group_id"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Nhóm khách hàng không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                if (streamProvider.FormData["source_id"] == null)
                {
                    response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                    response.Message = "Nguồn không được để trống";
                    response.Data    = null;
                    return(Ok(response));
                }
                // get data from formdata
                CustomerCreateViewModel customerCreateViewModel = new CustomerCreateViewModel
                {
                    cu_mobile   = Convert.ToString(streamProvider.FormData["cu_mobile"]),
                    cu_email    = Convert.ToString(streamProvider.FormData["cu_email"]),
                    cu_fullname = Convert.ToString(streamProvider.FormData["cu_fullname"]),

                    customer_group_id = Convert.ToInt32(streamProvider.FormData["customer_group_id"]),
                    source_id         = Convert.ToInt32(streamProvider.FormData["source_id"]),

                    cu_type = Convert.ToByte(streamProvider.FormData["cu_type"]),
                };
                //Bat cac dieu kien rang buoc
                if (CheckEmail.IsValidEmail(customerCreateViewModel.cu_email) == false && customerCreateViewModel.cu_email == "")
                {
                    response.Message = "Định dạng email không hợp lệ !";
                    response.Data    = null;
                    return(Ok(response));
                }

                if (CheckNumber.IsPhoneNumber(customerCreateViewModel.cu_mobile) == false && customerCreateViewModel.cu_mobile == "")
                {
                    response.Message = "Số điện thoại không hợp lệ";
                    response.Data    = null;
                    return(Ok(response));
                }


                //bat cac truog con lai
                if (streamProvider.FormData["cu_birthday"] == null)
                {
                    customerCreateViewModel.cu_birthday = null;
                }
                else
                {
                    customerCreateViewModel.cu_birthday = Convert.ToDateTime(streamProvider.FormData["cu_birthday"]);
                }
                if (streamProvider.FormData["cu_address"] == null)
                {
                    customerCreateViewModel.cu_address = null;
                }
                else
                {
                    customerCreateViewModel.cu_address = Convert.ToString(streamProvider.FormData["cu_address"]);
                }
                if (streamProvider.FormData["cu_note"] == null)
                {
                    customerCreateViewModel.cu_note = null;
                }
                else
                {
                    customerCreateViewModel.cu_note = Convert.ToString(streamProvider.FormData["cu_note"]);
                }
                if (streamProvider.FormData["cu_geocoding"] == null)
                {
                    customerCreateViewModel.cu_geocoding = null;
                }
                else
                {
                    customerCreateViewModel.cu_geocoding = Convert.ToString(streamProvider.FormData["cu_geocoding"]);
                }
                if (streamProvider.FormData["cu_curator_id"] == null)
                {
                    customerCreateViewModel.cu_curator_id = null;
                }
                else
                {
                    customerCreateViewModel.cu_curator_id = Convert.ToInt32(streamProvider.FormData["cu_curator_id"]);
                }
                if (streamProvider.FormData["cu_age"] == null)
                {
                    customerCreateViewModel.cu_age = null;
                }
                else
                {
                    customerCreateViewModel.cu_age = Convert.ToInt32(streamProvider.FormData["cu_age"]);
                }
                if (streamProvider.FormData["cu_status"] == null)
                {
                    customerCreateViewModel.cu_status = null;
                }
                else
                {
                    customerCreateViewModel.cu_status = Convert.ToByte(streamProvider.FormData["cu_status"]);
                }
                new BaseController();
                var current_id = BaseController.current_id;
                customerCreateViewModel.staff_id       = Convert.ToInt32(current_id);
                customerCreateViewModel.cu_create_date = DateTime.Now;
                var cu = _customerservice.GetLast();
                customerCreateViewModel.cu_code = Utilis.CreateCode("CU", cu.cu_id, 7);
                // mapping view model to entity
                var createdcustomer = _mapper.Map <customer>(customerCreateViewModel);
                createdcustomer.cu_thumbnail = fileName;
                // save new customer
                _customerservice.Create(createdcustomer);

                var get_last_id = _customerservice.GetLast();
                //Create address
                AddressCreateViewModel addressCreateViewModel = new AddressCreateViewModel
                {
                    add_province = Convert.ToString(streamProvider.FormData["add_province"]),

                    add_district = Convert.ToString(streamProvider.FormData["add_district"]),
                    add_ward     = Convert.ToString(streamProvider.FormData["add_ward"]),
                };
                addressCreateViewModel.customer_id = get_last_id.cu_id;
                var createAddress = _mapper.Map <address>(addressCreateViewModel);
                _addressservice.Create(createAddress);

                // return response
                response.Code    = HttpCode.OK;
                response.Message = MessageResponse.SUCCESS;
                response.Data    = createdcustomer;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                response.Message = ex.Message;
                response.Data    = null;
                Console.WriteLine(ex.ToString());

                return(Ok(response));
            }
        }