コード例 #1
0
 public ActionResult FileDelete(PictureFileRecord rec)
 {
     ChangeResult result = new ChangeResult();
     string status = PictureFileRecord.GetStatusString(rec.Status);
     bool display =
         rec.Status == PictureFileRecord.StatusType.Archived || rec.Status == PictureFileRecord.StatusType.ForSale;
     bool archive = rec.Status == PictureFileRecord.StatusType.Archived;
                 try
     {
         //List<PictureFileRecord> fileRecords =
         //    service.DeletePictureFile(rec.FileName, archive, display, service.FullyMappedPictureFolder).ToList();
         result = service.DeletePictureFile(rec.FileName, archive, display, service.FullyMappedPictureFolder);
     }
     catch (Exception anEx)
     {
         // log but don't halt execution - the javascript function has fired, possibly at an inappropriate time.
         // This is most likely because of not-fully-understood interaction between the paging control and onclick
         // event in webgrid
         Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Elmah.Error(anEx));
     }
     // RedirectToAction works by sending an http 302 response to browser which causes the
     // browser to make a GET request to the action - this is precisely what we want
     return RedirectToAction("Index", new { status = PictureFileRecord.GetStatusString(rec.Status), initial = false });
     //var jsondata = new
     //{
     //    data = result,
     //    view = RenderHelper.PartialView(this, (display) ? "_PictureList" : "_NonOrderablePictureList", load(status))
     //};
 }
コード例 #2
0
 /// <summary>
 /// Promotes the item in its list
 /// This action reduces the order number of the item by one if the order value is greater than zero. 
 /// The order value of the preceding item is increased by one.
 /// </summary>
 /// <param name="rec"></param>
 /// <returns></returns>
 public ActionResult FilePromote(PictureFileRecord rec)
 {
     ChangeResult result = new ChangeResult();
     try
     {
         result = service.AdvanceInList(rec);
     }
     catch (Exception anEx)
     {
         // log but don't halt execution
         Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Elmah.Error(anEx));
     }
     // RedirectToAction works by sending an http 302 response to browser which causes the
     // browser to make a GET request to the action - this is precisely what we want
     return RedirectToAction("Index", new { status = PictureFileRecord.GetStatusString(rec.Status), initial = false });
 }
コード例 #3
0
 public ChangeResult AdvanceInList(PictureFileRecord pfr)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
 public ChangeResult InsertShopPosting(PictureFileRecord pfr)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
 public ChangeResult InsertPosting(PictureFileRecord pfr, bool archive)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
 public ItemPostingViewModel CreateItemPostingViewModel(PictureFileRecord pfr)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
        public List<PictureFileRecord> PictureFileRecordList(string mappedfolder, string status = "All")
        {
            string fullyMappedPictureFolder = mappedfolder;
            List<PictureFileRecord> pictureFiles = new List<PictureFileRecord>();
            List<ItemPostingViewModel> postings = new List<ItemPostingViewModel>();
            postings.AddRange(ShopPostings().ToList());
            postings.AddRange(ArchivePostings().ToList());
            List<string> files = new List<string>();
            files = Directory.GetFiles(fullyMappedPictureFolder).ToList();
            foreach (string file in files)
            {
                PictureFileRecord pictureFile = new PictureFileRecord(file);
                ItemPostingViewModel vm = postings.Find(x => x.ItemPosting.FileName.ToUpper() == HttpUtility.UrlPathEncode(pictureFile.FileName.ToUpper()));
                if (vm == null)
                {
                    pictureFile.Status = PictureFileRecord.StatusType.NotDisplayed;
                    pictureFile.Order = PictureFileRecord.NULL_ORDER.ToString(PictureFileRecord.NullStringFormat);
                    pictureFile.Header = "";

                }
                else
                {
                    pictureFile.Order = vm.ItemPosting.Order.ToString();
                    pictureFile.Header = vm.ItemPosting.Header;
                    pictureFile.Status = (vm.ItemPosting.Archive_Flag)
                        ? PictureFileRecord.StatusType.Archived
                        : PictureFileRecord.StatusType.ForSale;
                }
                PictureFileRecord.StatusType statusType = PictureFileRecord.GetStatusType(status);
                if (pictureFile.Status == statusType || statusType == PictureFileRecord.StatusType.All)
                {
                    pictureFiles.Add(pictureFile);
                }
            }
            return pictureFiles;
        }
コード例 #8
0
        public ChangeResult MovePicture(string filepath, bool archivedestination, bool displaydestination)
        {
            // filepaths / names brought in from ajax call will have %20 spaces and will not have JS escaped single quotes
            string filename = Utility.GetFilenameFromFilepath(filepath).Normalise();

            // default constructor gives failed results
            ChangeResult removeResult = new ChangeResult();
            ChangeResult insertResult = new ChangeResult();
            // initialising variables
            PictureFileRecord pfr = new PictureFileRecord(filepath);
            PictureFileRecord.StatusType source;
            List<ItemPostingViewModel> postingVMs = new List<ItemPostingViewModel>();

            // getting current database contents
            postingVMs.AddRange(ArchivePostings().ToList());
            postingVMs.AddRange(ShopPostings().ToList());
            // getting full info on item to move
            ItemPostingViewModel moveItem = postingVMs.FirstOrDefault(x => x.ItemPosting.FileName.ToUpper().Normalise() == filename.ToUpper());
            ItemPosting posting = new ItemPosting();
            // determine current location of move item
            if (moveItem == null)
            {
                source = PictureFileRecord.StatusType.NotDisplayed;
            }
            else
            {
                posting = moveItem.ItemPosting;
                if (posting.Archive_Flag == true)
                {
                    source = PictureFileRecord.StatusType.Archived;
                }
                else
                {
                    source = PictureFileRecord.StatusType.ForSale;
                }
            }
            if (displaydestination)
            {
                // (1) the move item's being moved to the list it's already in
                if (archivedestination && source == PictureFileRecord.StatusType.Archived ||
                    !archivedestination && source == PictureFileRecord.StatusType.ForSale)
                {
                    return new ChangeResult(
                        false,
                        filename + " is already included in the " + ((archivedestination) ? "Archive" : "Home") + " page",
                        400);
                }
                else
                {
                    // (2) the moveItem's being moved from one list to another
                    if (archivedestination && source == PictureFileRecord.StatusType.ForSale ||
                        !archivedestination && source == PictureFileRecord.StatusType.Archived)
                    {
                        removeResult = RemoveFromDisplay(posting);
                        insertResult = InsertPosting(pfr, archivedestination);
                        return insertResult;
                    }
                    else
                    {
                        // (3) the moveItem's being moved onto a list from not_displayed
                        insertResult = InsertPosting(pfr, archivedestination);
                        return insertResult;
                    }
                }
            }
            // (4) the moveItem's being removed from all lists
            else
            {
                if (source == PictureFileRecord.StatusType.NotDisplayed)
                {
                    return new ChangeResult(
                        false,
                        filename + " is not currently displayed, and therefore is not in the database. Therefore it cannot be removed from the database",
                        500);
                }
                else
                {
                    removeResult = RemoveFromDisplay(posting);
                    return removeResult;
                }
            }
        }
コード例 #9
0
        ItemPostingViewModel IPostingService.CreateItemPostingViewModel(PictureFileRecord pfr)
        {
            ItemPosting posting = new ItemPosting();
            posting.FileName = Utility.GetFilenameFromFilepath(pfr.FilePath);
            posting.FilePath = pfr.FilePath;
            posting.Archive_Flag = true;
            posting.Description = "";
            posting.Header = "";
            posting.Order = 0;
            posting.Price = "";
            posting.ShortName = "";
            posting.Size = "";
            posting.Title = "";

            ItemPostingViewModel vm = new ItemPostingViewModel();
            vm.Editing = false;
            vm.ItemPosting = posting;
            return vm;
        }
コード例 #10
0
 /// <summary>
 /// Promotes the item in its list
 /// This action reduces the order number of the item by one if the order value is greater than zero. 
 /// The order value of the preceding item is increased by one.
 /// </summary>
 /// <param name="rec"></param>
 /// <returns></returns>
 ChangeResult IPostingService.AdvanceInList(PictureFileRecord rec)
 {
     ChangeResult result = new ChangeResult();
     int order;
     bool archive = rec.Status == PictureFileRecord.StatusType.Archived;
     string encodedFilename = HttpUtility.UrlPathEncode(rec.FileName);
     ItemPosting subjectItem = repository.GetPosting(x => x.FileName.ToUpper() == encodedFilename.ToUpper(), archive);
     try
     {
         order = Convert.ToInt32(subjectItem.Order);
         if (order > 0)
         {
             // get previously ordered item
             ItemPosting precedingItem = repository.GetPosting(pre => pre.Order == subjectItem.Order - 1, archive);
             result = repository.ExchangeOrders(subjectItem, precedingItem, archive);
         }
         else
         {
             result = new ChangeResult(false, "Cannot promote item which is at the top of the list", 400);
         }
     }
     catch (Exception anEx)
     {
         // log but don't halt execution - the javascript function has fired, most likely because
         // of difficult-to-understand interaction between the paging control and onclick event in webgrid
         Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Elmah.Error(anEx));
     }
     return result;
 }
コード例 #11
0
 public ChangeResult InsertPosting(PictureFileRecord pfr, bool archive)
 {
     // The constructor ItemPosting(string filename, bool archived) defaults the Order value to 0
     ItemPosting SQLPosting = extractSQLItemPosting(new ItemPosting(Utility.GetFilenameFromFilepath(pfr.FilePath), archive));
     ChangeResult result = repository.Create(SQLPosting, archive);
     return result;
 }