コード例 #1
0
        public ActionResult SubmitNew(PostedNewSerieModel model)
        {
            var items      = new List <UploadedSerieItem>();
            var filesnames = model.filenameOrder.Split(',');

            foreach (var filename in filesnames)
            {
                var file = model.files.First(f => f.FileName == filename);
                items.Add(new UploadedSerieItem
                {
                    Filename = filename,
                    Stream   = file.InputStream
                });
            }

            _createSerieCommand.SerieName   = model.name;
            _createSerieCommand.SerieItems  = items;
            _createSerieCommand.ProjectId   = model.projectId;
            _createSerieCommand.ProjectName = model.newProjectName;

            if (model.publicationDate.HasValue())
            {
                _createSerieCommand.PublicationDate = DateTime.Parse(model.publicationDate);
            }

            _createSerieCommand.Handle();

            return(RedirectToAction("Index", "Serie", new { area = "Admin", id = _createSerieCommand.StoredSerieId }));
        }
コード例 #2
0
        public ActionResult SubmitEdit(PostedNewSerieModel model)
        {
            var serie       = new GetSerieByIdCommand().Handle(model.SerieId);
            var items       = new List <UploadedSerieItem>();
            var filesnames  = model.filenameOrder.Split(',');
            var rankCounter = 0;

            foreach (var filename in filesnames)
            {
                var file = model.files.FirstOrDefault(f => f != null && f.FileName == filename);
                if (file != null)
                {
                    items.Add(new UploadedSerieItem
                    {
                        Filename = filename,
                        Stream   = file.InputStream,
                        Rank     = rankCounter,
                    });
                }
                else
                {
                    items.Add(new UploadedSerieItem {
                        Filename = Path.GetFileName(filename),
                        Rank     = rankCounter,
                    });
                }
                rankCounter++;
            }

            _editSerieCommand.SerieId     = model.SerieId;
            _editSerieCommand.SerieName   = model.name;
            _editSerieCommand.SerieItems  = items;
            _editSerieCommand.ProjectId   = model.projectId;
            _editSerieCommand.ProjectName = model.newProjectName;

            if (model.publicationDate.HasValue())
            {
                _editSerieCommand.PublicationDate = DateTime.Parse(model.publicationDate);
            }

            _editSerieCommand.Handle();

            return(RedirectToAction("Index", "Serie", new { area = "Admin", id = _createSerieCommand.StoredSerieId }));
        }