예제 #1
0
        public ActionResult WriterArchive(RenderModel model, int id, string name, FILTER filter = FILTER.Recommendations, int page = 1)
        {
            IPublishedContent recommendationsRespository = Helper.TypedContentAtRoot().FirstOrDefault()
                                                           .FirstChild(x => x.DocumentTypeAlias == Constants.NodeAlias.RECOMMENDATIONS_REPOSITORY);

            IPublishedContent articleRespository = Helper.TypedContentAtRoot().FirstOrDefault()
                                                   .FirstChild(x => x.DocumentTypeAlias == Constants.NodeAlias.ARTICLE_REPOSISTORY);

            IPublishedContent locationRespository = Helper.TypedContentAtRoot().FirstOrDefault()
                                                    .FirstChild(x => x.DocumentTypeAlias == Constants.NodeAlias.LOCATION_REPOSITORY);

            WriterModel writerModel = WriterFactory
                                      .Create(model.Content, recommendationsRespository, articleRespository, locationRespository, Site.IsEnglish, false, Services.ContentService, filter, page);

            string expectedName = writerModel.Name.ToSeoUrl();

            string actualName = (name ?? "").ToLower();

            // permanently redirect to the correct URL
            if (expectedName != actualName)
            {
                return(RedirectToActionPermanent(Constants.Controllers.WriterArchive.NAME,
                                                 Constants.Controllers.WriterArchive.Actions.INDEX,
                                                 new
                {
                    id = writerModel.Id,
                    name = expectedName,
                    filter
                }));
            }

            return(CurrentTemplate(writerModel));
        }
예제 #2
0
        public JsonResult AddNewWriter(WriterModel model)
        {
            using (var db = new Context())
            {
                try
                {
                    var writer = new Writer
                    {
                        ID         = db.UserRoles.Where(sh => model.username.Contains(sh.username)).FirstOrDefault().ID,
                        name       = model.name,
                        surrname   = model.surrname,
                        orchidURL  = model.orchidURL,
                        privateURL = model.privateURL,
                        property   = model.property
                    };
                    db.Writers.Add(writer);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(Json(new { success = false, responsemessage = e.ToString() }));
                }

                return(Json(new { success = true, responsemessage = "ok" }));
            }
        }
예제 #3
0
        public ActionResult NewsAdd(WriterModel model)
        {
            if (ModelState.IsValid)
            {
                List <Gallery> fotoList = new List <Gallery>();
                News           AddNew   = new News();
                AddNew.NewsContent = RemoveHtml.Delete(model.NewsContent);
                AddNew.CreateDate  = DateTime.Now;
                AddNew.CategoryId  = model.News.CategoryId;
                AddNew.NewsTitle   = model.NewsTitle;
                AddNew.UserId      = 2;
                news.Add(AddNew);
                foreach (HttpPostedFileBase file in model.files)
                {
                    //Checking file is available to save.
                    if (file != null)
                    {
                        var     InputFileName  = Path.GetFileName(file.FileName);
                        var     ServerSavePath = Path.Combine(Server.MapPath("~/Assets/img/") + InputFileName);
                        Gallery newPage        = new Gallery();
                        newPage.ImagePath = "Assets/img/" + InputFileName;
                        newPage.NewsId    = news.GetAll().Select(x => x.NewsId).LastOrDefault();
                        fotoList.Add(newPage);
                        gallery.Add(newPage);
                        //Save file to server folder
                        file.SaveAs(ServerSavePath);
                    }
                }
            }

            ViewBag.Kayit = "Kaydedildi";
            return(RedirectToAction("Writer", "Login", null));
        }
예제 #4
0
        public DistributorModule(AsyncTaskModule async, AsyncDbWorkModule asyncDbWork,
                                 WriterNetModule writerNet,
                                 ServerId local,
                                 HashMapConfiguration hashMapConfiguration,
                                 QueueConfiguration configuration,
                                 DbModuleCollection dbModuleCollection,
                                 AsyncTasksConfiguration pingConfiguration = null)
        {
            Contract.Requires(local != null);
            Contract.Requires(writerNet != null);
            Contract.Requires(configuration != null);
            Contract.Requires(asyncDbWork != null);
            Contract.Requires(async != null);
            Contract.Assert(dbModuleCollection != null);

            _async              = async;
            _asyncDbWork        = asyncDbWork;
            _model              = new WriterModel(local, hashMapConfiguration);
            _writerNet          = writerNet;
            _queueConfiguration = configuration;
            _dbModuleCollection = dbModuleCollection;
            _queue              = GlobalQueue.Queue;

            var ping = TimeSpan.FromMinutes(1);

            if (pingConfiguration != null)
            {
                ping = pingConfiguration.TimeoutPeriod;
            }

            _async.AddAsyncTask(
                new AsyncDataPeriod(ping, Ping, AsyncTasksNames.AsyncPing, -1), false);
        }
예제 #5
0
        public IActionResult EditForm(int id)
        {
            WriterModel foundWriter = _context.writers.FirstOrDefault(writer => writer.id == id);

            if (foundWriter != null)
            {
                return(View(foundWriter));
            }
            else
            {
                ViewData["error"] = "No writer found";
                return(View("Error"));
            }
        }
예제 #6
0
        public IActionResult DeleteWriter(int writerID)
        {
            WriterModel foundWriter = _context.writers.FirstOrDefault(writer => writer.id == writerID);

            if (foundWriter != null)
            {
                _context.Remove(foundWriter);
                _context.SaveChanges();
                // return Content($"Delete");
                return(RedirectToAction("ViewAll", "Primary"));
            }
            else
            {
                ViewData["error"] = "No writer found to delete";
                return(View("Error"));
            }
        }
예제 #7
0
 public IActionResult AddWriter(WriterModel newWriter)
 {
     if (ModelState.IsValid)
     {
         _context.writers.Add(newWriter);
         _context.SaveChanges();
         // return Content($"Added {newWriter.id}");
         return(RedirectToAction("ViewAll", "Primary"));
     }
     else
     {
         string        displayErr = "";
         List <string> errors     = GetErrorListFromModelState(ModelState);
         errors.ForEach(err => displayErr += $" {err} ");
         ViewData["errors"] = displayErr;
         return(View("WriterForm", newWriter));
     }
 }
예제 #8
0
        public IWriter GetWriter(WriterModel model)
        {
            SentinelHelper.ArgumentNull(model);
            SentinelHelper.ArgumentNull(model.Filter);

            var lazy = from item in _writers
                       let metadata = item.Metadata
                                      where metadata.Name == model.Name
                                      select item;

            if ((model.Filter.WriterStyles & KnownWriterFilter.Version) == KnownWriterFilter.Version)
            {
                lazy = from item in lazy
                       let metadata = item.Metadata
                                      where metadata.Version == int.Parse(model.Filter.Version, CultureInfo.InvariantCulture)
                                      select item;
            }

            if ((model.Filter.WriterStyles & KnownWriterFilter.Author) == KnownWriterFilter.Author)
            {
                lazy = from item in lazy
                       let metadata = item.Metadata
                                      where (metadata.Author == model.Filter.Author)
                                      select item;
            }

            if ((model.Filter.WriterStyles & KnownWriterFilter.Company) == KnownWriterFilter.Company)
            {
                lazy = from item in lazy
                       let metadata = item.Metadata
                                      where (metadata.Company == model.Filter.Company)
                                      select item;
            }

            var writer = lazy.SingleOrDefault();

            if (writer != null)
            {
                return(writer.Value);
            }

            throw new InvalidOperationException(Resources.ErrorMessage.CacheWriterNotFound);
        }
        public ActionResult Writer()
        {
            ViewBag.Ad = LoginName;
            WriterModel           model      = new WriterModel();
            List <Category>       categories = category.GetAll();
            List <SelectListItem> ListItem   = new List <SelectListItem>();

            foreach (var item in categories)
            {
                SelectListItem yeniItem = new SelectListItem();
                yeniItem.Value = item.CategoryId.ToString();
                yeniItem.Text  = item.CategoryName;
                ListItem.Add(yeniItem);
            }
            model.CategoryList = ListItem;
            News news = new News();

            model.News = news;
            return(View(model));
        }
예제 #10
0
        public IActionResult UpdateWriter(WriterModel updateWriter)
        {
            WriterModel foundWriter = _context.writers.FirstOrDefault(writer => writer.id == updateWriter.id);

            if (ModelState.IsValid)
            {
                foundWriter.fName       = updateWriter.fName;
                foundWriter.lName       = updateWriter.lName;
                foundWriter.age         = updateWriter.age;
                foundWriter.isPublished = updateWriter.isPublished;
                _context.SaveChanges();
                // return Content($"Update");
                return(RedirectToAction("ViewAll", "Primary"));
            }
            else
            {
                string        displayErr = "";
                List <string> errors     = GetErrorListFromModelState(ModelState);
                errors.ForEach(err => displayErr += $" {err} ");
                ViewData["errors"] = displayErr;
                return(View("EditForm", updateWriter));
            }
        }