public ViewResult DeleteCustomer(int Id)
        {
            try
            {
                if (Id != 0)
                {
                    Data.Customers.CutomerLibrary.DeleteCustomer(Id);
                }

                var result       = new List <CustomerProject.Models.Customer>();
                var customerList = Data.Customers.CutomerLibrary.GetCustomersFromDBAsync().Result;
                foreach (var item in customerList)
                {
                    Models.Customer modelCustomer = new Models.Customer
                    {
                        FirstName    = item.FirstName,
                        ID           = item.ID,
                        CustomerName = item.CustomerName,
                        Age          = item.Age,
                        ImagePath    = _bucketURL + item.ImagePath,
                        IsActive     = item.IsActive
                    };
                    //modelCustomer.ImageFullPath = await Common.Helpers.AwsAdapter.AwsS3FileDownload(_bucketName, _folderName, customerList.First().ImagePath);
                    result.Add(modelCustomer);
                }

                ViewBag.CustomerList = result;
                var customer = new CustomerProject.Models.Customer();
                return(View(customer));
            }
            catch (Exception e)
            {
                //ViewBag.ErrorMessage = e.ToString();
                return(View("Error"));
            }
        }
        public async Task <ViewResult> Customers(Models.Customer newCustomer, HttpPostedFileBase avatar)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Data.Customers.Customer dataCust = new Data.Customers.Customer()
                    {
                        CustomerName = newCustomer.CustomerName,
                        FirstName    = newCustomer.FirstName,
                        Age          = newCustomer.Age,
                        IsActive     = newCustomer.IsActive,
                    };
                    if (avatar != null)
                    {
                        dataCust.ImagePath = avatar.FileName;
                    }
                    // Add customer to database


                    //Add customer avatar to AWS S3 storage
                    if (avatar != null)
                    {
                        var response = await Common.Helpers.AwsAdapter.AwsS3FileUpdload(_bucketName, _folderName, avatar);

                        dataCust.ImagePath = _folderName + "/" + avatar.FileName;
                    }

                    Data.Customers.CutomerLibrary.AddCustomer(dataCust);

                    var result       = new List <CustomerProject.Models.Customer>();
                    var customerList = await Data.Customers.CutomerLibrary.GetCustomersFromDBAsync();

                    foreach (var item in customerList)
                    {
                        Models.Customer modelCustomer = new Models.Customer
                        {
                            FirstName    = item.FirstName,
                            ID           = item.ID,
                            CustomerName = item.CustomerName,
                            Age          = item.Age,
                            ImagePath    = _bucketURL + item.ImagePath,
                            IsActive     = item.IsActive
                        };
                        //modelCustomer.ImageFullPath = await Common.Helpers.AwsAdapter.AwsS3FileDownload(_bucketName, _folderName, customerList.First().ImagePath);
                        result.Add(modelCustomer);
                    }

                    ViewBag.CustomerList = result;
                    newCustomer          = new CustomerProject.Models.Customer();
                    return(View(newCustomer));
                }
                else
                {
                    return(View(newCustomer));
                }
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = e.ToString();
                return(View("Error"));
            }
        }