public static void Create(int projectId, string[] selection) { using (var db = new ViolaContext()) { // mevcut iliþkiler silinir. foreach (var row in db.ProjectTeams.Where(x => x.ProjectId == projectId)) { db.ProjectTeams.Remove(row); } // yeni iliþkiler kaydedilir if (selection != null) { foreach (var id in selection) { var row = new ProjectTeam { ProjectId = projectId, UserId = id }; row.InitCreateValue(); db.ProjectTeams.Add(row); } } db.SaveChanges(); } }
public static void Create(int _taskId, string[] selection) { using (var db = new ViolaContext()) { // mevcut iliþkiler silinir. foreach (var row in db.TaskAssignedUsers.Where(x => x.TaskId == _taskId)) { db.TaskAssignedUsers.Remove(row); } // yeni iliþkiler kaydedilir if (selection != null) { foreach (var id in selection) { var row = new TaskAssignedUser { TaskId = _taskId, UserId = id }; row.InitCreateValue(); // eðer projeye ekibinde yer alan bir kullanýcý ise task ile iliþkilendirilir. if (Viola.Models.User.GetUsersAssignedToProject(Task.Find(_taskId).ProjectId).Where(x => x.Id == row.UserId).Any()) { db.TaskAssignedUsers.Add(row); } } } db.SaveChanges(); } }
public static IQueryable <User> GetUsers() { var db = new ViolaContext(); var curUser = Viola.Models.User.GetCurrentUser(); return(db.Users.Where(x => x.CompanyId == curUser.CompanyId).OrderBy(x => x.FullName)); }
public static IQueryable <Project> GetProjectsByRole() { IQueryable <Project> ret; var db = new ViolaContext(); var curUser = Viola.Models.User.GetCurrentUser(); // bütün projeler if (curUser.UserRole == UserRole.Admin) { ret = db.Projects.Where(x => x.CompanyId == curUser.CompanyId); } // user kendi oluþturduðu ve atandýðý projeleri görebilir else { ret = from p in db.Projects // mevcut kullanýcý proje ekibinde yer alýyormu kontrol et let pt = from pt in db.ProjectTeams where pt.ProjectId == p.Id && pt.UserId == curUser.Id select pt.UserId where p.CompanyId == curUser.CompanyId && (p.CreatedUserId == curUser.Id || pt.Contains(curUser.Id)) orderby p.Name select p; } return(ret); }
public static IQueryable <Task> GetTasksByRole() { IQueryable <Task> ret; var db = new ViolaContext(); var curUser = Viola.Models.User.GetCurrentUser(); // bütün tasklar if (curUser.UserRole == UserRole.Admin) { ret = db.Tasks.Where(x => x.CompanyId == curUser.CompanyId); } // user kendi oluþturduðu ve atandýðý projelere ait tasklarý görebilir else { ret = from p in db.Projects join t in db.Tasks on p.Id equals t.ProjectId // mevcut kullanýcý proje ekibinde yer alýyormu kontrol et let pt = from pt in db.ProjectTeams where pt.ProjectId == p.Id && pt.UserId == curUser.Id select pt.UserId where p.CompanyId == curUser.CompanyId && (p.CreatedUserId == curUser.Id || pt.Contains(curUser.Id)) orderby t.Id descending select t; } return(ret); }
public static IQueryable <Task> GetTasksByProjectId(int projectId) { var db = new ViolaContext(); var curUser = Viola.Models.User.GetCurrentUser(); return(from t in db.Tasks where t.CompanyId == curUser.CompanyId && t.ProjectId == projectId orderby t.Name select t); }
public static User GetUser(string userId, ViolaContext context = null) { if (context == null) { context = new ViolaContext(); } var userManager = new UserManager <User>(new UserStore <User>(context)); return(userManager.FindById(userId)); }
public static IQueryable <User> GetUsersAssignedToProject(int projectId) { var db = new ViolaContext(); var curUser = Viola.Models.User.GetCurrentUser(); return(from pt in db.ProjectTeams join u in db.Users on pt.UserId equals u.Id where u.CompanyId == curUser.CompanyId && pt.ProjectId == projectId orderby u.FullName select u); }
public static decimal SumSizeByTransDate(DateTime datetime) { var db = new ViolaContext(); string curUserId = Viola.Models.User.GetCurrentUserId(); var result = from e in db.Efforts where e.UserId == curUserId && e.TransDate == datetime select e; return(result.AsEnumerable().Sum(o => o.Size)); }
public UsersController() { context = new ViolaContext(); UserManager = new UserManager <User>(new UserStore <User>(context)); RoleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); // email adresinin userName olarak kaydedilmesi için UserManager.UserValidator = new UserValidator <User>(UserManager) { AllowOnlyAlphanumericUserNames = false }; }
public static IQueryable <User> GetUsersForEffort() { var db = new ViolaContext(); var curUser = Viola.Models.User.GetCurrentUser(); if (curUser.UserRole == UserRole.Admin) { return(GetUsers()); } else { return(GetUsers().Where(x => x.Id == curUser.Id)); } }
public static List <string> UserIdSelection(int projectId) { var ret = new List <string>(); using (var db = new ViolaContext()) { var rows = db.ProjectTeams.Where(x => x.ProjectId == projectId); foreach (var row in rows) { ret.Add(row.UserId); } } return(ret); }
public static List <string> UserIdSelection(int _projectId) { var ret = new List <string>(); using (var db = new ViolaContext()) { var rows = db.TaskAssignedUsers.Where(x => x.TaskId == _projectId); foreach (var row in rows) { ret.Add(row.UserId); } } return(ret); }
public static void AddProjectManagerToTeam(Project project) { var db = new ViolaContext(); if (!ProjectTeam.Exist(project.Id, project.ManagerUserId)) { var pt = new ProjectTeam() { ProjectId = project.Id, UserId = project.ManagerUserId }; pt.InitCreateValue(); db.ProjectTeams.Add(pt); db.SaveChanges(); } }
public static IQueryable <Effort> GetEffortsByRole() { IQueryable <Effort> ret; var db = new ViolaContext(); var curUser = Viola.Models.User.GetCurrentUser(); // bütün eforlar if (curUser.UserRole == UserRole.Admin) { return(db.Efforts.Where(x => x.CompanyId == curUser.CompanyId).OrderByDescending(x => x.TransDate)); } // user kendi girdiði eforlarý görür else { ret = from e in db.Efforts where e.CompanyId == curUser.CompanyId && e.UserId == curUser.Id orderby e.TransDate descending select e; } return(ret); }
public static Company GetCurrentCompany(ViolaContext context = null) { return(User.GetCurrentUser(context).Company); }
public static bool Exist(int taskId, string userId) { var db = new ViolaContext(); return(db.TaskAssignedUsers.Where(x => x.TaskId == taskId && x.UserId == userId).Any()); }
public static bool Exist(int projectId, string userId) { var db = new ViolaContext(); return(db.ProjectTeams.Where(x => x.ProjectId == projectId && x.UserId == userId).Any()); }
public static Task Find(int taskId) { var db = new ViolaContext(); return(db.Tasks.Where(x => x.Id == taskId).FirstOrDefault()); }
public static User GetCurrentUser(ViolaContext context = null) { return(GetUser(GetCurrentUserId(), context)); }