Add project files.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Web.Mvc;
|
||||
using System.Data.Entity;
|
||||
using atakanozbancom.Models.classes;
|
||||
|
||||
namespace atakanozbancom.Controllers
|
||||
{
|
||||
public class myprojectsController : Controller
|
||||
{
|
||||
private readonly Context c = new Context();
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public PartialViewResult projectposts()
|
||||
{
|
||||
var cultureFull = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
|
||||
var cultureShort = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
|
||||
var isEnglish = cultureShort == "en";
|
||||
|
||||
var model = c.MyProjects
|
||||
.Include(p => p.Translations)
|
||||
.Select(p => new MyProjectsVM
|
||||
{
|
||||
id = p.id,
|
||||
image = p.image,
|
||||
iframe = p.iframe,
|
||||
|
||||
title = !isEnglish
|
||||
? p.Translations
|
||||
.Where(t => t.culture == cultureFull || t.culture == cultureShort)
|
||||
.Select(t => t.title)
|
||||
.FirstOrDefault()
|
||||
?? p.title
|
||||
: p.title,
|
||||
|
||||
description = !isEnglish
|
||||
? p.Translations
|
||||
.Where(t => t.culture == cultureFull || t.culture == cultureShort)
|
||||
.Select(t => t.description)
|
||||
.FirstOrDefault()
|
||||
?? p.description
|
||||
: p.description
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return PartialView(model);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult myprojectsget(int id)
|
||||
{
|
||||
|
||||
var p = c.MyProjects
|
||||
.Include(x => x.Translations)
|
||||
.FirstOrDefault(x => x.id == id);
|
||||
if (p == null) return HttpNotFound();
|
||||
|
||||
var tr = p.Translations?.FirstOrDefault(t => t.culture == "tr" || t.culture == "tr-TR");
|
||||
|
||||
var vm = new AdminMyProjectsEditVM
|
||||
{
|
||||
id = p.id,
|
||||
image = p.image,
|
||||
iframe = p.iframe,
|
||||
|
||||
TitleEN = p.title,
|
||||
DescEN = p.description,
|
||||
|
||||
TitleTR = tr?.title ?? "",
|
||||
DescTR = tr?.description ?? ""
|
||||
};
|
||||
|
||||
return View("~/Views/admin/myprojectsget.cshtml", vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user