示例#1
0
        public ActionResult Edit(int id)
        {
            ViewBag.CurrentUser = CurrentUser;
            ViewBag.Department  = DepartmentBO.GetAll();
            var user = UserBO.GetById(id);

            if (user == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            var model = new UserModel()
            {
                Id           = user.Id,
                UserName     = user.UserName,
                FirstName    = user.FirstName,
                LastName     = user.LastName,
                Password     = EncryptUtils.Decrypt(user.Password),
                Address      = user.Address,
                Avatar       = user.Avatar,
                DateOfBirth  = user.DateOfBirth.ToString("dd/MM/yyyy"),
                DepartmentId = user.DepartmentId,
                Gender       = user.Gender,
                Email        = user.Email,
                Mission      = user.Mission,
                IsActive     = user.IsActive,
                IsAdmin      = user.IsAdmin
            };

            return(View("Create", model));
        }
示例#2
0
        public ActionResult Edit(UserModel model)
        {
            var user = UserBO.GetById(model.Id);

            if (user != null)
            {
                user.Avatar = model.Gender ? "/Content/img/avatar5.png" : "/Content/img/avatar3.png";
                DateTime date;
                if (DateTime.TryParseExact(model.DateOfBirth, "dd/MM/yyyy",
                                           new CultureInfo("en-US"),
                                           DateTimeStyles.None,
                                           out date))
                {
                    user.DateOfBirth = date;
                }

                UserBO.Update(user.Id, user.UserName, user.Password, model.FirstName, model.LastName, model.Address, user.DateOfBirth, model.Gender, model.DepartmentId, model.Email, model.Mission, user.Avatar, model.IsActive, model.IsAdmin, model.IsManager, user.CreateDate, DateTime.Now, user.CreateBy, CurrentUser.Id);
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Edit not succeed");
            }
            ViewBag.Department = DepartmentBO.GetAll();
            return(View("Create", model));
        }
示例#3
0
        public void PreparingData()
        {
            var listPriority = new List <dynamic>()
            {
                new
                {
                    Name  = Priority.High.GetDescription(),
                    Value = (byte)Priority.High
                },
                new
                {
                    Name  = Priority.Normal.GetDescription(),
                    Value = (byte)Priority.Normal
                },
                new
                {
                    Name  = Priority.Low.GetDescription(),
                    Value = (byte)Priority.Low
                },
            };

            ViewBag.Priorities  = listPriority;
            ViewBag.Departments = DepartmentBO.GetAll();
            ViewBag.Projects    = ProjectBO.GetAll();
        }
示例#4
0
        public ActionResult Create()
        {
            ViewBag.CurrentUser = CurrentUser;
            ViewBag.Department  = DepartmentBO.GetAll();
            var model = new UserModel {
                Gender = true, IsActive = true
            };

            return(View(model));
        }
示例#5
0
        public ActionResult Index(UserSearchModel searchModel)
        {
            var listUser = new List <UserDisplayModel>();

            if (searchModel == null)
            {
                searchModel = new UserSearchModel();
            }

            var departments = new List <Department>();

            departments.Add(new Department {
                Id = 0, Name = "--- All ---"
            });
            departments.AddRange(DepartmentBO.GetAll());
            ViewBag.Departments = departments;
            var users = UserBO.Search(searchModel.UserName, searchModel.FullName, searchModel.DepartmentId);

            foreach (var item in users)
            {
                var department = DepartmentBO.GetById(item.DepartmentId);
                var model      = new UserDisplayModel
                {
                    Id             = item.Id,
                    UserName       = item.UserName,
                    FirstName      = item.FirstName,
                    LastName       = item.LastName,
                    Password       = item.Password,
                    Address        = item.Address,
                    Avatar         = item.Avatar,
                    DateOfBirth    = item.DateOfBirth.ToString("dd/MM/yyyy"),
                    DepartmentId   = item.DepartmentId,
                    DepartmentName = department == null? string.Empty : department.Name,
                    Gender         = item.Gender,
                    Email          = item.Email,
                    Mission        = item.Mission,
                    IsActive       = item.IsActive,
                    IsAdmin        = item.IsAdmin,
                    CreatedDate    = item.CreateDate == null ? string.Empty : ((DateTime)item.CreateDate).ToString(Helper.FormatDate),
                };
                listUser.Add(model);
            }

            searchModel.Users = listUser;
            return(View(searchModel));
        }
        //
        // GET: /Department/

        public ActionResult Index()
        {
            var listDepartmentsModel = new List <DepartmentModel>();
            var listDepartments      = DepartmentBO.GetAll();

            foreach (var item in listDepartments)
            {
                var model = new DepartmentModel
                {
                    Id          = item.Id,
                    Name        = item.Name,
                    UserId      = item.UserId,
                    User        = UserBO.GetById(item.UserId),
                    CreatedDate = item.CreateDate == null ? string.Empty: ((DateTime)item.CreateDate).ToString(Helper.FormatDate),
                };
                listDepartmentsModel.Add(model);
            }
            return(View(listDepartmentsModel));
        }
示例#7
0
        public ActionResult Create(UserModel model)
        {
            if (Validate(model))
            {
                model.Avatar = model.Gender ? "/Content/img/avatar5.png" : "/Content/img/avatar3.png";
                DateTime date;
                if (!DateTime.TryParseExact(model.DateOfBirth, "dd/MM/yyyy",
                                            new CultureInfo("en-US"),
                                            DateTimeStyles.None,
                                            out date))
                {
                    date = DateTime.Now;
                }
                UserBO.Create(model.UserName, EncryptUtils.Encrypt(model.Password), model.FirstName, model.LastName, model.Address, date, model.Gender, model.DepartmentId, model.Email, model.Mission, model.Avatar, true, false, model.IsManager, DateTime.Now, DateTime.Now, CurrentUser.Id, CurrentUser.Id);
                return(RedirectToAction("Index"));
            }
            var departments = DepartmentBO.GetAll();

            ViewBag.Department = departments;
            return(View(model));
        }
示例#8
0
        //
        // GET: /Task/

        public ActionResult Index(TasksSearchModel searchModel)
        {
            var listTasks = new List <TasksDisplayModel>();

            if (searchModel == null)
            {
                searchModel = new TasksSearchModel
                {
                    StartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString(Helper.FormatDate),
                    EndDate   = new DateTime(DateTime.Now.Year, DateTime.Now.Month + 1, 1).AddDays(-1).ToString(Helper.FormatDate),
                };
            }
            DateTime sdate;
            DateTime edate;

            DateTime.TryParseExact(searchModel.StartDate, Helper.FormatDate,
                                   new CultureInfo("en-US"),
                                   DateTimeStyles.None,
                                   out sdate);
            DateTime.TryParseExact(searchModel.EndDate, Helper.FormatDate,
                                   new CultureInfo("en-US"),
                                   DateTimeStyles.None,
                                   out edate);

            var departments = new List <Department> {
                new Department {
                    UserId = 0, Name = "--- All ---"
                }
            };

            departments.AddRange(DepartmentBO.GetAll());
            ViewBag.Departments = departments;

            var projects = new List <Project> {
                new Project {
                    Id = 0, Name = "--- All ---"
                }
            };

            projects.AddRange(ProjectBO.GetAll());
            ViewBag.Projects = projects;

            var tasks = TaskBO.Search(searchModel.Name, searchModel.Leader, sdate, edate);

            foreach (var item in tasks)
            {
                var department = DepartmentBO.GetById(item.Leader);
                var project    = ProjectBO.GetById(item.ProjectId);
                var model      = new TasksDisplayModel
                {
                    Id          = item.Id,
                    ProjectId   = item.ProjectId,
                    ProjectName = project.Name,
                    Name        = item.Name,
                    Description = item.Description,
                    Leader      = item.Leader,
                    LeaderName  = department.Name,
                    Priority    = item.Priority,
                    StartDate   = item.StartDate,
                    EndDate     = item.EndDate,
                    User        = UserBO.GetById(item.Leader),
                    CreatedDate = item.CreateDate == null ? string.Empty : ((DateTime)item.CreateDate).ToString(Helper.FormatDate),
                };

                if (CurrentUser.IsManager || CurrentUser.DepartmentLeader == item.Leader)
                {
                    listTasks.Add(model);
                }
            }
            searchModel.Tasks = listTasks;
            return(View(searchModel));
        }