public ActionResult AccountManagerPicture(string databaseName, string customerId, string companyId)
        {
            APIAuth  auth     = new APIAuth(Request, Response);
            AuthInfo authInfo = auth.CheckLogin();

            if (authInfo.IsAuthenticated)
            {
                Customer localCust = new Customer();
                localCust.DatabaseName = databaseName;
                localCust.CustomerId   = customerId;
                localCust.CompanyId    = companyId;

                //Check if this user has access to this customer
                var userCustomers = db.GetUserCustomersSync(authInfo.User.Id);

                if (userCustomers.Count(x => x.CustomerKey == localCust.CustomerKey) > 0)
                {
                    // Get the customer's account manager's details
                    AccountManager accountManager = new OverviewDAL().GetAccountManagerDetailsSync(localCust).FirstOrDefault();

                    // Get the URL for the account manager's image
                    string accountManagerImageURL = DownloadsHelper.GetAccountManagerImageURL(accountManager.Email);

                    // Download the account manager image
                    WebClient webClient = new WebClient();
                    byte[]    accountManagerImageBytes = webClient.DownloadData(accountManagerImageURL);

                    // Return the account manager image as bytes
                    return(File(accountManagerImageBytes, System.Net.Mime.MediaTypeNames.Image.Jpeg));
                }
                else
                {
                    return(auth.Forbidden());
                }
            }
            else
            {
                return(auth.Forbidden());
            }
        }
Esempio n. 2
0
        public Dictionary <DateTime, int> GetModDownloadsIncrease(int id)
        {
            List <Download> downloads = (List <Download>) this.GetDownloadByDate(id, new DateTime(), Grouping.Day).Result.Value;

            return(DownloadsHelper.GetDownloadsIncrease(downloads));
        }