Exemple #1
0
        public PartialViewResult RateImage(IFormCollection collection, ImageAction action)
        {
            var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));

            action.Action     = "Rating";
            action.ActionDate = DateTime.Now;
            action.AppUserId  = signedInUserId;
            action.OwnerId    = signedInUserId;
            action.ImageId    = Convert.ToInt64(collection["ImageId"]);
            action.Rating     = Convert.ToInt64(collection["rating"]);
            action.ClientId   = new AppConfig().ClientId;
            if (_databaseConnection.ImageActions
                .Where(n => n.ImageId == action.ImageId && n.AppUserId == action.AppUserId).ToList().Count <= 0)
            {
                _databaseConnection.Add(action);
                _databaseConnection.SaveChanges();
            }
            var image        = _databaseConnection.Images.SingleOrDefault(n => n.ImageId == action.ImageId);
            var appTransport = new AppTransport
            {
                AppUsers     = _users,
                Images       = _databaseConnection.Images.ToList(),
                ImageActions = _databaseConnection.ImageActions.ToList(),
                Image        = image,
                AppUser      = _users.SingleOrDefault(n => n.AppUserId == signedInUserId)
            };

            return(PartialView("Partials/_PartialRating", appTransport));
        }
Exemple #2
0
        public async Task <ActionResult> SingleImage(long id, long?notificationId)
        {
            var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));

            //update notification to read
            if (notificationId != null)
            {
                var notification = _pushNotifications.SingleOrDefault(n => n.PushNotificationId == notificationId);

                if (notification != null)
                {
                    notification.Read             = true;
                    notification.DateLastModified = DateTime.Now;
                    notification.LastModifiedBy   = signedInUserId;
                    await new AppUserFactory().UpdatePushNotification(new AppConfig().UpdatePushNotifications,
                                                                      notification);
                }
            }

            //populate object
            var appTransport = new AppTransport
            {
                AppUsers = _users,
                Images   = _databaseConnection.Images.Include(n => n.ImageCategory)
                           .Include(n => n.ImageComments).Include(n => n.ImageTags)
                           .Include(n => n.Location).Include(n => n.ImageSubCategory).ToList(),
                ImageComments = _databaseConnection.ImageComments.ToList(),
                ImageActions  = _databaseConnection.ImageActions.ToList(),
                Image         = _databaseConnection.Images.Find(id),
                AppUser       = _users.SingleOrDefault(n => n.AppUserId == signedInUserId)
            };

            return(View(appTransport));
        }
        private static void NewOrderReaction(object p)
        {
            var info = new ProcessStartInfo {
                FileName = AppTransport.GetHostAppFileName()
            };
            var e = (NewOrderEventArgs)p;

            info.Arguments = BusinessObjectsEnum.Order.GetName() + " " + e.OrderDocument.Customer.GetName() + string.Join(" ", e.OrderDocument.OrderFileNames);
            Process.Start(info);
        }
        public IActionResult Dashboard()
        {
            var appTransport = new AppTransport();

            appTransport.AppUsers       = _databaseConnection.AppUsers.Where(n => n.RoleId != 1).ToList();
            appTransport.CurrentBalance =
                (decimal)(_databaseConnection.Transactions.Include(n => n.TransactionType).Where(n => n.TransactionType.Credit).Sum(n => n.Amount) -
                          _databaseConnection.Transactions.Include(n => n.TransactionType).Where(n => n.TransactionType.Debit).Sum(n => n.Amount));
            appTransport.Transactions = _databaseConnection.Transactions.Include(n => n.TransactionType).ToList();
            return(View(appTransport));
        }
Exemple #5
0
        public PartialViewResult ReloadImageComments(long?id)
        {
            var imageComments = _databaseConnection.ImageComments.Where(n => n.ImageId == id).ToList();

            var appTransport = new AppTransport
            {
                ImageComments = imageComments,
                AppUsers      = _users
            };

            return(PartialView("Partials/_ImageComment", appTransport));
        }
Exemple #6
0
        public async Task <PartialViewResult> PostImageComment(ImageComment comment, IFormCollection collection)
        {
            long?imageId        = Convert.ToInt64(collection["ImageId"]);
            var  image          = _databaseConnection.Images.Find(imageId);
            var  signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));

            comment.DateCreated      = DateTime.Now;
            comment.AppUserId        = signedInUserId;
            comment.ImageId          = imageId;
            comment.Comment          = collection["Comment"].ToString();
            comment.CreatedBy        = signedInUserId;
            comment.LastModifiedBy   = signedInUserId;
            comment.DateLastModified = DateTime.Now;
            _databaseConnection.ImageComments.Add(comment);
            _databaseConnection.SaveChanges();

            //send notification for owner of photo
            if (image.AppUserId != comment.CreatedBy)
            {
                var notification = new PushNotification
                {
                    AppUserId        = image.AppUserId,
                    CreatedBy        = signedInUserId,
                    LastModifiedBy   = signedInUserId,
                    DateLastModified = DateTime.Now,
                    DateCreated      = DateTime.Now,
                    Category         = SystemNotificationCategory.Comment.ToString(),
                    Read             = false,
                    ControllerId     = imageId
                };
                var singleOrDefault = _users.SingleOrDefault(n => n.AppUserId == comment.CreatedBy);
                if (singleOrDefault != null)
                {
                    notification.Message = singleOrDefault.Name +
                                           " Commented on your Image";
                }
                await new AppUserFactory().SavePushNotification(new AppConfig().SavePushNotifications, notification);
            }
            var newComments  = _databaseConnection.ImageComments.Where(n => n.ImageId == imageId).ToList();
            var appTransport = new AppTransport
            {
                ImageComments = newComments,
                AppUsers      = _users,
                Images        = _databaseConnection.Images.Include(n => n.ImageCategory)
                                .Include(n => n.ImageComments).Include(n => n.ImageTags)
                                .Include(n => n.Location).Include(n => n.ImageSubCategory).ToList(),
                ImageActions = _databaseConnection.ImageActions.ToList(),
                Image        = image,
                AppUser      = _users.SingleOrDefault(n => n.AppUserId == signedInUserId)
            };

            return(PartialView("Partials/_ImageComment", appTransport));
        }
Exemple #7
0
        public ActionResult Profile()
        {
            var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
            var appTransport   = new AppTransport
            {
                AppUsers = _users,
                Images   = _databaseConnection.Images.Include(n => n.ImageCategory).Include(n => n.ImageTags)
                           .Include(n => n.Location).OrderByDescending(n => n.DateCreated).ToList(),
                ImageComments = _databaseConnection.ImageComments.ToList(),
                ImageActions  = _databaseConnection.ImageActions.ToList(),
                AppUser       = _users.SingleOrDefault(n => n.AppUserId == signedInUserId)
            };

            return(View(appTransport));
        }
Exemple #8
0
        public ActionResult UserProfile(long id)
        {
            var appTransport = new AppTransport
            {
                AppUsers = _users,
                Images   = _databaseConnection.Images.Include(n => n.ImageCategory)
                           .Include(n => n.ImageComments).Include(n => n.ImageTags)
                           .Include(n => n.Location).Include(n => n.ImageSubCategory).Where(n => n.AppUserId == id)
                           .OrderByDescending(n => n.DateCreated).ToList(),
                ImageComments = _databaseConnection.ImageComments.ToList(),
                ImageActions  = _databaseConnection.ImageActions.ToList(),
                Image         = _databaseConnection.Images.Find(id),
                AppUser       = _users.SingleOrDefault(n => n.AppUserId == id)
            };

            return(View(appTransport));
        }
Exemple #9
0
        public PartialViewResult DeleteComment(IFormCollection collection)
        {
            long?commentId = Convert.ToInt64(collection["CommentId"]);
            long?imageId   = Convert.ToInt64(collection["ImageId"]);
            var  image     = _databaseConnection.Images.Find(imageId);
            var  comment   = _databaseConnection.ImageComments.Find(commentId);

            _databaseConnection.ImageComments.Remove(comment);
            _databaseConnection.SaveChanges();
            var newComments  = _databaseConnection.ImageComments.Where(n => n.ImageId == imageId).ToList();
            var appTransport = new AppTransport
            {
                ImageComments = newComments,
                AppUsers      = _users,
                Images        = _databaseConnection.Images.Include(n => n.ImageCategory)
                                .Include(n => n.ImageComments).Include(n => n.ImageTags)
                                .Include(n => n.Location).Include(n => n.ImageSubCategory).ToList(),
                ImageActions = _databaseConnection.ImageActions.ToList(),
                Image        = image
            };

            return(PartialView("Partials/_ImageComment", appTransport));
        }
Exemple #10
0
        public async Task <IActionResult> Dashboard()
        {
            AppTransport appTransport = null;

            if (HttpContext.Session.GetString("StudioLoggedInUser") != null &&
                HttpContext.Session.GetString("StudioLoggedInUserId") != null)
            {
                var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
                var userString     = HttpContext.Session.GetString("StudioLoggedInUser");
                _appUser = JsonConvert.DeserializeObject <AppUser>(userString);

                //update keys
                var updatedKeys = await new AppUserFactory().UpdateAccountActivationAccessKey(
                    new AppConfig().UpdateAccountActivationAccessKey, _appUser.AppUserId);
                if (updatedKeys.AppUserAccessKeyId > 0)
                {
                    //display notification
                    TempData["display"]          = "Welcome back " + _appUser.Name + " our awesome photographer!";
                    TempData["notificationtype"] = NotificationType.Success.ToString();
                }
                //validate bank details
                if (_appUser != null && _appUser.Role.UploadImage)
                {
                    if (_databaseConnection.UserBanks.Where(n => n.CreatedBy == _appUser.AppUserId).ToList().Count <= 0)
                    {
                        //populate and save bank transaction
                        var newUserBank = new UserBank
                        {
                            CreatedBy        = _appUser.AppUserId,
                            LastModifiedBy   = _appUser.AppUserId,
                            DateCreated      = DateTime.Now,
                            DateLastModified = DateTime.Now
                        };
                        _databaseConnection.UserBanks.Add(newUserBank);
                        _databaseConnection.SaveChanges();
                    }
                    else
                    {
                        var userBank =
                            _databaseConnection.UserBanks.SingleOrDefault(n => n.CreatedBy == _appUser.AppUserId);
                        if (userBank != null && (string.IsNullOrEmpty(userBank.AccountName) || userBank.BankId <= 0 ||
                                                 string.IsNullOrEmpty(userBank.AccountName) &&
                                                 HttpContext.Session.GetString("UserBank") == null))
                        {
                            var bankString = JsonConvert.SerializeObject(userBank);
                            HttpContext.Session.SetString("UserBank", bankString);
                        }
                        else
                        {
                            HttpContext.Session.Remove("UserBank");
                        }
                    }
                }
                //store data temporarily, based on the user role
                if (_appUser != null && _appUser.Role.ManageImages)
                {
                    appTransport = new AppTransport
                    {
                        Images    = _databaseConnection.Images.ToList(),
                        Cameras   = _databaseConnection.Cameras.ToList(),
                        Locations = _databaseConnection.Locations.ToList(),
                        Orders    = new OrderFactory().GetAllOrdersAsync(new AppConfig().FetchOrdersUrl).Result.ToList(),
                        Payments  = new OrderFactory().GetAllPaymentsAsync(new AppConfig().FetchPaymentsUrl).Result
                                    .ToList(),
                        ImageDownloads = new ImageFactory().GetAllDownloads(new AppConfig().GetImageDownloadsUrl).Result,
                        AppUser        = _appUser
                    };
                }
                if (_appUser != null && _appUser.Role.UploadImage)
                {
                    appTransport = new AppTransport
                    {
                        Images  = _databaseConnection.Images.Where(n => n.AppUserId == signedInUserId).ToList(),
                        Cameras = _databaseConnection.Cameras
                                  .Where(n => n.CreatedBy == signedInUserId).ToList(),
                        Locations = _databaseConnection.Locations
                                    .Where(n => n.CreatedBy == signedInUserId).ToList(),
                        Orders = new OrderFactory().GetAllOrdersAsync(new AppConfig().FetchOrdersUrl)
                                 .Result.Where(n => n.CreatedBy == signedInUserId).ToList(),
                        Payments = new OrderFactory().GetAllPaymentsAsync(new AppConfig().FetchPaymentsUrl).Result
                                   .Where(n => n.AppUserId == signedInUserId)
                                   .ToList(),
                        ImageDownloads = new ImageFactory().GetAllDownloads(new AppConfig().GetImageDownloadsUrl).Result,
                        AppUser        = _appUser
                    };
                }
                //validate mapping
                if (appTransport != null)
                {
                    appTransport.AppUsers = new AppUserFactory().GetAllUsers(new AppConfig().FetchUsersUrl).Result
                                            .ToList();
                }
                return(View(appTransport));
            }
            return(Redirect("https://camerack.com/Account/Login?returnUrl=sessionExpired"));
        }