public async Task <IActionResult> Create(int jid, [Bind("Name,Releasedate,Cover,Pdf,Number,JournalId,VolumeId,IsPublished,IsOpen,Visitors,PdfDownloadCounter")] JournalIssue journalIssue, IFormFile myfile, IFormFile myfile1)
        {
            if (ModelState.IsValid)
            {
                journalIssue.Pdf = await UserFile.UploadeNewFileAsync(journalIssue.Pdf,
                                                                      myfile, _environment.WebRootPath, Properties.Resources.Secured);

                journalIssue.Cover = await UserFile.UploadeNewImageAsync(journalIssue.Cover,
                                                                         myfile1, _environment.WebRootPath, Properties.Resources.Images, 100, 150);

                _context.Add(journalIssue);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", new { id = jid }));
            }
            ViewData["JournalId"] = new SelectList(_context.Journals.Where(a => a.Id == jid), "Id", "ArName", journalIssue.JournalId);
            ViewData["VolumeId"]  = new SelectList(_context.Volumes.Where(a => a.JournalId == jid), "Id", "Id", journalIssue.VolumeId);
            return(View(journalIssue));
        }
Пример #2
0
        public void Save()
        {
            bool needSave = false;

            if (SortMainId > 0)
            {
                var o = SortMainObject.GetSortMain(SortMainId);
                if (o != null)
                {
                    if (JournalType != o.JournalType)
                    {
                        o.JournalType = JournalType;
                        needSave      = true;
                    }

                    if (JournalName?.Trim() != o.JournalName)
                    {
                        o.JournalName = JournalName?.Trim();
                        needSave      = true;
                    }

                    if (JournalVolume?.Trim() != o.JournalVolume)
                    {
                        o.JournalVolume = JournalVolume?.Trim();
                        needSave        = true;
                    }

                    if (JournalIssue?.Trim() != o.JournalIssue)
                    {
                        o.JournalIssue = JournalIssue.Trim();
                        needSave       = true;
                    }

                    if (JournalSerial?.Trim() != o.JournalSerial)
                    {
                        o.JournalSerial = JournalSerial?.Trim();
                        needSave        = true;
                    }

                    if (JournalStartPage != o.JournalStartPage)
                    {
                        o.JournalStartPage = JournalStartPage;
                        needSave           = true;
                    }

                    if (JournalEndPage != o.JournalEndPage)
                    {
                        o.JournalEndPage = JournalEndPage;
                        needSave         = true;
                    }

                    if (JournalDoi?.Trim() != o.JournalDoi)
                    {
                        o.JournalDoi = JournalDoi?.Trim();
                        needSave     = true;
                    }

                    if (needSave)
                    {
                        o.Save();
                    }
                }
            }
        }