public async Task <IActionResult> Save(Project model)
        {
            var user = HttpContext.Session.GetInt32("userid");

            model.ManagerId = user ?? 1;
            model.Url       = FriendlyURL.GetURLFromTitle(model.Title);
            await _baseService.Save(model);

            return(Redirect($"/{model.Url}"));
        }
        public async Task <IActionResult> Update(Project model)
        {
            var item = await _baseService.Get <Project>(model.Id);

            item.Title       = model.Title;
            item.Explanation = model.Explanation;
            item.Url         = FriendlyURL.GetURLFromTitle(item.Title);
            await _baseService.Save(item);

            return(Redirect($"/{item.Url}"));
        }
        public async Task <IActionResult> Update(Work model)
        {
            var item = await _baseService.Get <Work>(model.Id);

            item.Title       = model.Title;
            item.Url         = FriendlyURL.GetURLFromTitle(model.Title);
            item.Explanation = model.Explanation;
            await _baseService.Save(item);

            //await TelegramBot.SendAsync($"Bir iş güncellendi  {model.Id} {item.Title}");

            return(Redirect($"/work/{item.Url}"));
        }
        private ArticuloViewModel ProcesarArticulo(ArticuloViewModel model)
        {
            model.Articulo.TituloSeo = FriendlyURL.SeekUrl(model.Articulo.Titulo, name => !db.Articulos.Any(t => t.TituloSeo == name && t.ArticuloId != model.Articulo.ArticuloId));

            var tags = new List <string>();

            if (!string.IsNullOrWhiteSpace(model.Tags))
            {
                tags = model.Tags.ToLower().Split(',').ToList();
            }
            var listaTags = new List <Tag>();

            if (model.Articulo.Tags == null)
            {
                model.Articulo.Tags = new List <Tag>();
            }

            foreach (var tag in tags)
            {
                var existeTag = db.Tags.FirstOrDefault(t => t.Descripcion == tag);
                if (existeTag == null)
                {
                    Tag nuevoTag = new Tag()
                    {
                        Descripcion    = tag,
                        DescripcionSeo = FriendlyURL.SeekUrl(tag, name => !db.Tags.Any(t => t.DescripcionSeo == name))
                    };
                    db.Tags.Add(nuevoTag);
                    db.SaveChanges();
                }
            }

            // Remove deselected skills
            model.Articulo.Tags.Where(m => !tags.Contains(m.Descripcion))
            .ToList().ForEach(tag => model.Articulo.Tags.Remove(tag));

            // Add new skills
            var existingSkillIds = model.Articulo.Tags.Select(m => m.Descripcion);

            db.Tags.Where(m => tags.Except(existingSkillIds).Contains(m.Descripcion))
            .ToList().ForEach(tag => model.Articulo.Tags.Add(tag));



            return(model);
        }
        public async Task <IActionResult> Save(Work model)
        {
            model.Url = FriendlyURL.GetURLFromTitle(model.Title);
            await _baseService.Save(model);

            await _baseService.Save(new WorkHistory
                                    { PrevStatus = model.Status, WorkId = model.Id, ManagerId = model.ManagerId });

            await _baseService.Save(new WorkLabels { WorkId = model.Id, LabelId = 1 });

            if (model.ParentWorkId.HasValue)
            {
                var work = await _baseService.Get <Work>(model.ParentWorkId.Value);

                //await TelegramBot.SendAsync($"Yeni bir alt iş oluşturuldu  {model.Id} {model.Title}  Üst İş : {work.Title}");
                return(Redirect($"/work/{work.Url}"));
            }

            var project = await _baseService.Get <Project>(model.ProjectId);

            //await TelegramBot.SendAsync($"Yeni bir iş oluşturuldu {model.Id} {model.Title}  Proje : {project.Title}");
            return(Redirect($"/{project.Url}"));
        }
Exemple #6
0
 //constructor function
 public General()
 {
     string[] Config = retrieveConfig();
     if (Config[0] != "false")
     {
         DB     = new Database(Config[0], Config[2], Config[3], Config[4], Config[1], Config[5]);
         Auth   = new Authentication();
         Styles = new Styles();
         Users  = new Users();
         FUrl   = new FriendlyURL();
         Cpcha  = new Captcha();
         getConfigWebSite();
     }
     else
     {
         EnableWebSite   = false;
         sTitle          = "John Mendes";
         LogoImage       = "1.gif";
         MediaType       = "Image";
         FolderInstalled = "";
     }
     //General g = Session["app"] as General;
 }