Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,Heading,Description,File")] Image image)
        {
            if (ModelState.IsValid)
            {
                if (SignInManager.IsSignedIn(User))
                {
                    UplaodToGallery(image);
                    _context.Add(image);
                    await _context.SaveChangesAsync();

                    var publisher = (from publishers in _context.Publisher

                                     where publishers.EmailAddresss.Equals(User.Identity.Name)
                                     select publishers).FirstOrDefault();

                    UploadRecord record = new UploadRecord();

                    record.ImageId     = image.Id;
                    record.PublisherId = publisher.Id;
                    record.UploadTime  = DateTime.Now;

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

                    return(RedirectToAction(nameof(Index), "UploadRecords"));
                }
            }
            return(View(image));
        }
        public async Task <IActionResult> Create([Bind("Id,EmailAddresss")] Publisher publisher)
        {
            if (ModelState.IsValid)
            {
                _context.Add(publisher);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(publisher));
        }