Пример #1
0
        public IActionResult Faq(Faq faq)
        {
            var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));

            faq.DateLastModified = DateTime.Now;
            faq.LastModifiedBy   = signedInUserId;

            _databaseConnection.Entry(faq).State = EntityState.Modified;
            _databaseConnection.SaveChanges();
            TempData["display"]          = "You have successfully modified the FAQ!";
            TempData["notificationtype"] = NotificationType.Success.ToString();
            return(RedirectToAction("Dashboard", "Home"));
        }
Пример #2
0
        /// <summary>
        ///     The method returns a single images via a json object
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult UpdateAdCount(long id)
        {
            var ad = _databaseConnection.Advertisements.Find(id);

            ad.AdClick = ad.AdClick + 1;
            _databaseConnection.Entry(ad).State = EntityState.Modified;
            _databaseConnection.SaveChanges();
            return(Json(ad));
        }
Пример #3
0
        public ActionResult Edit(Advertisement advertisement, IList <IFormFile> image, IFormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
                advertisement.DateLastModified = DateTime.Now;
                advertisement.LastModifiedBy   = signedInUserId;
                if (_databaseConnection.Advertisements
                    .Where(n => n.EndDate > advertisement.StartDate && n.PageCategory == advertisement.PageCategory &&
                           n.AdvertisementId != advertisement.AdvertisementId)
                    .ToList().Count <= 0)
                {
                    if (image.Count > 0)
                    {
                        foreach (var file in image)
                        {
                            var fileInfo      = new FileInfo(file.FileName);
                            var ext           = fileInfo.Extension.ToLower();
                            var name          = DateTime.Now.ToFileTime().ToString();
                            var fileName      = name + ext;
                            var uploadedImage = new AppConfig().AdvertPicture + fileName;
                            using (var fs = System.IO.File.Create(uploadedImage))
                            {
                                if (fs != null)
                                {
                                    file.CopyTo(fs);
                                    fs.Flush();
                                    advertisement.File = fileName;
                                }
                            }
                        }
                    }
                    _databaseConnection.Entry(advertisement).State = EntityState.Modified;
                    _databaseConnection.SaveChanges();

                    //display notification
                    TempData["display"]          = "You have successfully modified the Advertisement!";
                    TempData["notificationtype"] = NotificationType.Success.ToString();
                    return(RedirectToAction("Index"));
                }

                //display notification
                TempData["display"] = "The advert cannot be scheduled for the category at the set time" +
                                      ", check the category and time constraints!";
                TempData["notificationtype"] = NotificationType.Error.ToString();
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
        public ActionResult Edit(PhotographerCategory photographerCategory, IList <IFormFile> image,
                                 IFormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
                photographerCategory.DateLastModified = DateTime.Now;
                photographerCategory.LastModifiedBy   = signedInUserId;
                if (image.Count > 0)
                {
                    foreach (var file in image)
                    {
                        var fileInfo      = new FileInfo(file.FileName);
                        var ext           = fileInfo.Extension.ToLower();
                        var name          = DateTime.Now.ToFileTime().ToString();
                        var fileName      = name + ext;
                        var uploadedImage = new AppConfig().PhotoCategoryPicture + fileName;
                        using (var fs = System.IO.File.Create(uploadedImage))
                        {
                            if (fs != null)
                            {
                                file.CopyTo(fs);
                                fs.Flush();
                                photographerCategory.FileName = fileName;
                            }
                        }
                    }
                }
                _databaseConnection.Entry(photographerCategory).State = EntityState.Modified;
                _databaseConnection.SaveChanges();

                //display notification
                TempData["display"]          = "You have successfully modified the Image Category!";
                TempData["notificationtype"] = NotificationType.Success.ToString();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #5
0
        public ActionResult Edit(Location location, IFormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
                location.DateLastModified = DateTime.Now;
                location.LastModifiedBy   = signedInUserId;

                _databaseConnection.Entry(location).State = EntityState.Modified;
                _databaseConnection.SaveChanges();

                //display notification
                TempData["display"]          = "You have successfully modified the Location!";
                TempData["notificationtype"] = NotificationType.Success.ToString();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(ImageSubCategory imageSubCategory)
        {
            try
            {
                // TODO: Add update logic here
                var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
                imageSubCategory.DateLastModified = DateTime.Now;
                imageSubCategory.LastModifiedBy   = signedInUserId;

                _databaseConnection.Entry(imageSubCategory).State = EntityState.Modified;
                _databaseConnection.SaveChanges();

                //display notification
                TempData["display"]          = "You have successfully modified the Image Sub-Category!";
                TempData["notificationtype"] = NotificationType.Success.ToString();
                return(RedirectToAction("Index", new { id = imageSubCategory.ImageCategoryId }));
            }
            catch
            {
                return(View());
            }
        }
Пример #7
0
        public ActionResult UserBank(UserBank userBank)
        {
            try
            {
                //populate object and save transaction
                var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
                userBank.LastModifiedBy   = signedInUserId;
                userBank.DateLastModified = DateTime.Now;

                _databaseConnection.Entry(userBank).State = EntityState.Modified;
                _databaseConnection.SaveChanges();

                if (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");
                }
                //display notification
                TempData["display"]          = "You have successfully updated your bank information";
                TempData["notificationtype"] = NotificationType.Success.ToString();
                return(RedirectToAction("Profile"));
            }
            catch (Exception ex)
            {
                //display notification
                TempData["display"]          = ex.ToString();
                TempData["notificationtype"] = NotificationType.Error.ToString();
                return(View(userBank));
            }
        }
Пример #8
0
        public async Task <ActionResult> ApproveOrRejectImage(long id, string status)
        {
            var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId"));
            var image          = _databaseConnection.Images.Find(id);

            if (status == ImageStatus.Accepted.ToString())
            {
                image.Status = ImageStatus.Accepted.ToString();
            }
            if (status == ImageStatus.Rejected.ToString())
            {
                image.Status = ImageStatus.Rejected.ToString();
            }
            var imageFile = "https://res.cloudinary.com/" + image.FilePath;


            //upload image via Cloudinary API Call
            var account = new Account(
                new AppConfig().CloudinaryAccoutnName,
                new AppConfig().CloudinaryApiKey,
                new AppConfig().CloudinaryApiSecret);

            var cloudinary = new Cloudinary(account);
            var delParams  = new DelResParams
            {
                PublicIds = new List <string> {
                    imageFile
                },
                Invalidate = true
            };
            await cloudinary.DeleteResourcesAsync(delParams);

            var tags = _databaseConnection.ImageTags.Where(n => n.ImageId == image.ImageId);

            foreach (var item in tags)
            {
                _databaseConnection.ImageTags.RemoveRange(item);
            }
            var imageActions = _databaseConnection.ImageActions.Where(n => n.ImageId == image.ImageId);

            foreach (var item in imageActions)
            {
                _databaseConnection.ImageActions.RemoveRange(item);
            }
            var imageComments = _databaseConnection.ImageComments.Where(n => n.ImageId == image.ImageId);

            foreach (var item in imageComments)
            {
                _databaseConnection.ImageComments.RemoveRange(item);
            }
            var imageReports = _databaseConnection.ImageReports.Where(n => n.ImageId == image.ImageId);

            foreach (var item in imageReports)
            {
                _databaseConnection.ImageReports.RemoveRange(item);
            }

            _databaseConnection.Entry(image).State = EntityState.Modified;
            _databaseConnection.SaveChanges();

            image.DateLastModified = DateTime.Now;
            image.LastModifiedBy   = signedInUserId;
            _databaseConnection.Entry(image).State = EntityState.Modified;
            _databaseConnection.SaveChanges();

            //display notification
            TempData["display"]          = "You have successfully " + image.Status + " the image!";
            TempData["notificationtype"] = NotificationType.Success.ToString();
            return(RedirectToAction("Index"));
        }