예제 #1
0
 public AuthorRepository()
 {
     _context = new TaskManagerContext();
 }
        public override async Task <Company> Execute(TaskManagerContext context)
        {
            var company = await context.Companies.Where(x => x.Id == CompanyId).Include(x => x.EmployeesList).Include(x => x.Manager).SingleOrDefaultAsync(x => x.Id == Id);

            return(company);
        }
        public override async Task <Board> Execute(TaskManagerContext context)
        {
            var board = await context.Boards.Include(x => x.AssignmentList).Include(x => x.Employee).SingleOrDefaultAsync(x => x.Id == Id);

            return(board);
        }
예제 #4
0
        public List <Project> GetProjects()
        {
            var context = new TaskManagerContext();

            return(context.Projects.ToList());
        }
예제 #5
0
 public RepositoryUsers()
 {
     context = new TaskManagerContext();
 }
예제 #6
0
 public TaskService(TaskManagerContext context)
 {
     _context = context;
 }
예제 #7
0
 public PersonService(TaskManagerContext context)
 {
     _context = context;
 }
예제 #8
0
 public SubtaskRepository(TaskManagerContext context) : base(context)
 {
 }
예제 #9
0
 public async Task Update(User user)
 {
     TaskManagerContext.Update(user);
     await TaskManagerContext.SaveChangesAsync();
 }
예제 #10
0
        static void Main(string[] args)
        {
            using (TaskManagerContext db = new TaskManagerContext("name=TaskManagerContext"))
            {
                //ApplicationUser user = new ApplicationUser { };
                //Person person = new Person { }
                //db.People.Add();
                //Console.WriteLine("I was running");

                //IUnitOfWork inst = new UnitOfWork("name=TaskManagerContex");
                //IUnitOfWork_Identity identity = new UnitOfWork_Identity("name=TaskManagerContex");
                //var user = new ApplicationUser { Email = "dcdnsndcnjsn1", UserName = "******" };
                //var result = identity.UserManager.CreateIdentityAsync(user, "1233123");
                ////result.
                //var user_1 = identity.UserManager.FindByNameAsync(user.UserName);

                //var res = identity.UserManager.AddToRoleAsync(user_1.Result.Id, "Manageree");

                //var person = new Personе { ApplicationUser = new ApplicationUser { Id = user_1.Result.Id }, Name = user_1.Result.UserName, Email = user.Email, Position = "FFF" };
                //int answear = inst.People.Create(person);

                //Console.WriteLine(answear);
                //Console.WriteLine();

                //db.People.Add();
                Console.WriteLine(db.Database.Connection.ToString());

                IUnitOfWork          inst     = new UnitOfWork("name=TaskManagerContext");
                IUnitOfWork_Identity identity = new UnitOfWork_Identity("name=TaskManagerContext");
                var user = new ApplicationUser {
                    Email = "ddnsndcnjsn", UserName = "******"
                };
                var result = identity.UserManager.CreateAsync(user, "1233123");
                var res    = identity.UserManager.AddToRoleAsync(user.Id, "Manager");
                var person = new Person {                 /*Application*User = user,*/
                    Name = user.UserName, Email = user.Email, Position = "Manager"
                };
                user.Person = person;
                identity.UserManager.UpdateAsync(user);
                person.User = user;
                int answear = inst.People.Create(person);

                Console.WriteLine(answear);
                Console.WriteLine();
            }
            Console.WriteLine("The end of connection");
            Console.ReadKey();
            //	var i=MyMethAsync();
            //using (TaskManagerContext db = new TaskManagerContext("name=TaskManagerContext"))
            //{
            //	Console.WriteLine(db.Database.Connection.ToString());

            //	IUnitOfWork inst = new UnitOfWork("name=TaskManagerContext");
            //	IUnitOfWork_Identity identity = new UnitOfWork_Identity("name=TaskManagerContext");
            //	var user = new ApplicationUser { Email = "dcdnsndcnjsn", UserName = "******" };
            //	var result = identity.UserManager.CreateAsync(user, "1233123");
            //	var res = identity.UserManager.AddToRole(user.Id, "Manager");
            //	var person = new Person { ApplicationUserId = user.Id, Name = user.UserName, Email = user.Email };
            //	int answear = inst.People.Create(person);

            //	Console.WriteLine(answear);
            //	Console.WriteLine(	);
            //}
            //Console.ReadLine();
        }
예제 #11
0
 public UserRepository(TaskManagerContext context) : base(context)
 {
 }
 public HomeController(TaskManagerContext context)
 {
     _context = context;
 }
예제 #13
0
 public List<Task> GetTasks(int projectId)
 {
     var context = new TaskManagerContext();
     return context.Tasks.Where(x => x.ProjectId == projectId).ToList();
 }
예제 #14
0
 public UserRepository(TaskManagerContext context)
 {
     _context = context;
 }
 public TagAssignmentsController(TaskManagerContext context)
 {
     _context = context;
 }
예제 #16
0
 public List<Project> GetProjects()
 {
     var context = new TaskManagerContext();
     return context.Projects.ToList();
 }
예제 #17
0
 public RepositoryCategories()
 {
     context = new TaskManagerContext();
 }
예제 #18
0
        public async Task SetupAsync()
        {
            var options = new DbContextOptionsBuilder <TaskManagerContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            this.context = new TaskManagerContext(options);
            var u1 = new User
            {
                EmployeeID = 1,
                FirstName  = "Tanmay",
                LastName   = "Vartak",
                UserID     = 1
            };

            var p1 = new Project
            {
                ProjectID   = 1,
                ProjectName = "EY",
                Priority    = 1,
                ManagerID   = 1,
                StartDate   = DateTime.Now,
                EndDate     = DateTime.Now.AddDays(2),
            };

            this.context.Users.Add(u1);
            this.context.SaveChanges();

            this.context.Projects.Add(p1);
            this.context.SaveChanges();

            var t1 = new Tasks
            {
                Name      = "Task 1",
                TasksID   = 1,
                ParentID  = 0,
                EndDate   = DateTime.Now.AddDays(7),
                Priority  = 1,
                StartDate = DateTime.Now,
                UserID    = 1,
                ProjectID = 1
            };
            var t2 = new Tasks
            {
                Name      = "Task 2",
                TasksID   = 2,
                ParentID  = 1,
                EndDate   = DateTime.Now.AddDays(5),
                Priority  = 1,
                StartDate = DateTime.Now,
                UserID    = 1,
                ProjectID = 1
            };
            var t3 = new Tasks
            {
                Name      = "Task 3",
                TasksID   = 3,
                ParentID  = 2,
                EndDate   = DateTime.Now,
                Priority  = 1,
                StartDate = DateTime.Now.AddDays(-5),
                UserID    = 1,
                ProjectID = 1
            };

            this.context.Tasks.AddRange(new Tasks[]
            {
                t1, t2, t3
            });

            await this.context.SaveChangesAsync();

            this.context.Entry <User>(u1).State    = EntityState.Detached;
            this.context.Entry <Project>(p1).State = EntityState.Detached;
            this.context.Entry <Tasks>(t1).State   = EntityState.Detached;
            this.context.Entry <Tasks>(t2).State   = EntityState.Detached;
            this.context.Entry <Tasks>(t3).State   = EntityState.Detached;

            //setup controller object;
            this.controller = new ProjectsController(this.context);
        }
예제 #19
0
        public ActionResult Index(ChiefTaskViewModel model)
        {
            if (model == null)
            {
                model = new ChiefTaskViewModel();
            }
            if (model.ChiefTaskList == null)
            {
                model.ChiefTaskList = new List <ChiefTaskList>();
            }

            if (model.FilterTaskViewModel == null)
            {
                model.FilterTaskViewModel = new FilterTaskViewModel
                {
                    ArchiveFilter     = false,
                    CompleteFilter    = false,
                    StartDateFilter   = null,
                    EndDateFilter     = null,
                    NotAssignedFilter = false,
                    OverdueFilter     = false,
                    SearchText        = string.Empty,
                    SelectedRecipient = string.Empty
                };
            }
            List <Task> tasks;

            try
            {
                using (var context = new TaskManagerContext())
                {
                    tasks = context.Tasks.Where(x => model.FilterTaskViewModel.ArchiveFilter ? x.AcceptCpmpleteDate != null : x.AcceptCpmpleteDate == null)
                            .Include(x => x.Comments)
                            .Include(x => x.TaskSender)
                            .Include(x => x.TaskRecipient)
                            .Include(x => x.TaskPriority)
                            .ToList();
                    if (model.FilterTaskViewModel.CompleteFilter)
                    {
                        tasks = tasks.Where(x => x.CompleteDate != null).ToList();
                    }
                    if (model.FilterTaskViewModel.NotAssignedFilter)
                    {
                        tasks = tasks.Where(x => x.RecipientId == null).ToList();
                    }
                    if (model.FilterTaskViewModel.OverdueFilter)
                    {
                        tasks = tasks.Where(x => x.Deadline.HasValue && x.Deadline.Value.Date < DateTime.Now.Date).ToList();
                    }
                    if (!string.IsNullOrEmpty(model.FilterTaskViewModel.SelectedRecipient) && model.FilterTaskViewModel.SelectedRecipient != "0")
                    {
                        tasks = tasks.Where(x => x.RecipientId.HasValue && x.RecipientId.ToString().Equals(model.FilterTaskViewModel.SelectedRecipient)).ToList();
                    }
                    if (model.FilterTaskViewModel.StartDateFilter.HasValue)
                    {
                        tasks = tasks.Where(x => x.CreateDate >= model.FilterTaskViewModel.StartDateFilter.Value).ToList();
                    }
                    if (model.FilterTaskViewModel.EndDateFilter.HasValue)
                    {
                        tasks = tasks.Where(x => x.AcceptCpmpleteDate.HasValue && x.AcceptCpmpleteDate <= model.FilterTaskViewModel.EndDateFilter.Value).ToList();
                    }
                    if (!string.IsNullOrEmpty(model.FilterTaskViewModel.SearchText))
                    {
                        tasks = tasks.Where(x => x.TaskText.ToLower().Contains(model.FilterTaskViewModel.SearchText.ToLower())).ToList();
                    }
                    model.RecipientList = ModelHelper.GetRecipientsSelectedList("Все исполнители", "0", context);
                }
            }
            catch (Exception)
            {
                throw;
            }

            tasks.ForEach(x => model.ChiefTaskList.Add(new ChiefTaskList
            {
                AcceptCompleteDate = x.AcceptCpmpleteDate,
                CompleteDate       = x.CompleteDate,
                CreationDate       = x.CreateDate,
                Deadline           = x.Deadline,
                PriorityId         = x.TaskPriority != null ? x.TaskPriority.PriorityId.ToString() : "0",
                RecipientId        = x.TaskRecipient != null ? x.TaskRecipient.UserId : (int?)null,
                RecipientName      = x.TaskRecipient != null ? x.TaskRecipient.UserFullName : "не назначен",
                ResultComment      = (x.CompleteDate.HasValue && string.IsNullOrEmpty(x.ResultComment)) ? "выполнено" : x.ResultComment,
                SenderName         = x.TaskSender.UserFullName,
                TaskText           = x.TaskText,
                TaskId             = x.TaskId
            }));

            model.ChiefTaskList = model.ChiefTaskList.OrderBy(x => x.RecipientId.HasValue).ThenByDescending(x => x.CreationDate).ThenBy(x => x.PriorityId).ThenBy(x => x.Deadline).ToList();

            if (Request.IsAjaxRequest())
            {
                return(PartialView("TaskListAjax", model));
            }
            return(View(model));
        }
예제 #20
0
 protected BaseRepository(TaskManagerContext context)
 {
     TaskManagerContext = context;
 }
예제 #21
0
        public ActionResult Edit(ChiefTaskEditViewModel model)
        {
            try
            {
                using (var context = new TaskManagerContext())
                {
                    var task = context.Tasks.FirstOrDefault(x => x.TaskId == model.TaskId);
                    if (task != null)
                    {
                        int recipId;
                        if (int.TryParse(model.RecipientId, out recipId))
                        {
                            if ((task.RecipientId == null && recipId != 0) || (task.RecipientId != null && task.RecipientId != recipId))
                            {
                                task.TaskEeventLogs.Add(new TaskEeventLog
                                {
                                    EventDateTime = DateTime.Now,
                                    PropertyName  = "RecipientId",
                                    UserId        = WebSecurity.CurrentUserId,
                                    OldValue      = task.RecipientId.HasValue ? task.RecipientId.Value.ToString() : null,
                                    NewValue      = recipId == 0 ? null : recipId.ToString()
                                });
                                task.RecipientId       = recipId == 0 ? (int?)null : recipId;
                                task.IsRecipientViewed = false;
                            }
                        }
                        if (recipId == 0)
                        {
                            task.AssignDateTime = null;
                            task.Deadline       = null;
                        }
                        else
                        {
                            DateTime date;
                            if (DateTime.TryParse(model.Deadline, out date))
                            {
                                if (task.Deadline != date)
                                {
                                    task.TaskEeventLogs.Add(new TaskEeventLog
                                    {
                                        EventDateTime = DateTime.Now,
                                        PropertyName  = "Deadline",
                                        UserId        = WebSecurity.CurrentUserId,
                                        OldValue      = task.Deadline.HasValue ? task.Deadline.Value.ToString(ModelHelper.DateFormat) : null,
                                        NewValue      = date.ToString(ModelHelper.DateFormat)
                                    });
                                    task.Deadline          = date;
                                    task.AssignDateTime    = DateTime.Now;
                                    task.IsRecipientViewed = false;
                                }
                            }
                            else
                            {
                                ModelState.AddModelError("Deadline", "Назначьте срок исполнения");
                                model.PrioritiesList = ModelHelper.GetPrioritiesSelectedList(model.PriorityId, context);
                                model.RecipientsList = ModelHelper.GetRecipientsSelectedList("не назначен", model.RecipientId, context);
                                return(View(model));
                            }
                        }

                        int priorId;
                        if (int.TryParse(model.PriorityId, out priorId))
                        {
                            if (task.PriorityId != priorId)
                            {
                                task.TaskEeventLogs.Add(new TaskEeventLog
                                {
                                    EventDateTime = DateTime.Now,
                                    PropertyName  = "PriorityId",
                                    OldValue      = task.PriorityId.HasValue ? task.PriorityId.Value.ToString() : null,
                                    NewValue      = priorId.ToString(),
                                    UserId        = WebSecurity.CurrentUserId
                                });
                                task.PriorityId = priorId;
                            }
                        }
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(RedirectToAction("Index"));
        }
예제 #22
0
 public TasksController(TaskManagerContext context)
 {
     _context = context;
 }
 public ProjectRepository(TaskManagerContext context) : base(context)
 {
 }
        public override async Task <List <Customer> > Execute(TaskManagerContext context)
        {
            var customers = await context.Customers.Where(x => x.CompanyId == CompanyId).Include(x => x.AssignmentList).ToListAsync();

            return(customers);
        }
예제 #25
0
 public abstract Task <TResult> Execute(TaskManagerContext context);
예제 #26
0
        public List <Task> GetTasks(int projectId)
        {
            var context = new TaskManagerContext();

            return(context.Tasks.Where(x => x.ProjectId == projectId).ToList());
        }
 public TaskManagerRepository(TaskManagerContext tmContext)
 {
     taskManagerContext = tmContext ?? throw new ArgumentNullException(nameof(tmContext));
 }
예제 #28
0
 public UnitOfWork(string connectionString)
 {
     db = new TaskManagerContext(connectionString);
 }
예제 #29
0
 PersonManager userCreater;        //We call PersonManager to create an instance for new person.
 public PersonRepository(TaskManagerContext context)
 {
     db          = context;
     userCreater = new PersonManager(context);
 }
예제 #30
0
 public StatusRepository(TaskManagerContext context)
 {
     db = context;
 }
예제 #31
0
 public TeamRepository(TaskManagerContext context)
 {
     db = context;
 }
예제 #32
0
        public override async Task <List <Company> > Execute(TaskManagerContext context)
        {
            var companies = await context.Companies.Where(x => x.Id == CompanyId).Include(x => x.EmployeesList).Include(x => x.Manager).ToListAsync();

            return(companies);
        }
예제 #33
0
 public TaskBoardRepository()
 {
     context = new TaskManagerContext();
 }