예제 #1
0
        private void UpdateDueDateTsManager(int id, int tsId)
        {
            var userUpdate = _userService.GetDetail(id);

            var userTsManagerModel = _userTsManagerService.GetDetail(tsId);

            var addDay = Common.NumberOfWorkDays(DateTime.Now, WebConfigure.GetApprovalTsManagerDay());

            if (tsId == 1)
            {
                userUpdate.UserTsManager1Id      = userTsManagerModel.UserTsManagerId;
                userUpdate.UserTsManager1Name    = userTsManagerModel.Name;
                userUpdate.UserTsManager1DueDate = DateTime.Now.AddDays(addDay);
            }
            else if (tsId == 2)
            {
                userUpdate.UserTsManager2Id      = userTsManagerModel.UserTsManagerId;
                userUpdate.UserTsManager2Name    = userTsManagerModel.Name;
                userUpdate.UserTsManager2DueDate = DateTime.Now.AddDays(addDay);
            }
            else if (tsId == 3)
            {
                userUpdate.UserTsManager3Id      = userTsManagerModel.UserTsManagerId;
                userUpdate.UserTsManager3Name    = userTsManagerModel.Name;
                userUpdate.UserTsManager3DueDate = DateTime.Now.AddDays(addDay);
            }

            userUpdate.UserTsManagerDueFlag = tsId;

            _userService.Edit(userUpdate);
        }
        public ActionResult Approve2Mail(User user, FormCollection collect)
        {
            string token = Common.AccessToken() + user.EmployeeId;

            token = token.Replace("/", "");
            token = token.Replace("+", "");

            var employeeM = _mstEmployeeBService.GetDetail(user.Approval2);

            var userTsManagerModel = _userTsManagerBusinessService.GetDetail(1);
            var Spv1 = _mstEmployeeBService.GetDetail(_mstEmployeeBService.GetDetail(user.EmployeeId).Superior_ID);
            var Spv2 = _mstEmployeeBService.GetDetail(Spv1.Superior_ID);
            //next to approval 2
            var userT = _userBService.GetDetail(user.UserId);

            userT.Status        = 5;
            userT.UpdatedAt     = DateTime.Now;
            userT.MobileToken   = token;
            userT.NameApproval2 = employeeM.Employee_Name;
            userT.DateApproval2 = DateTime.Now;

            userT.UserTsManager1Id   = userTsManagerModel.UserTsManagerId;
            userT.UserTsManager1Name = userTsManagerModel.Name;
            var addDay = Common.NumberOfWorkDays(DateTime.Now, WebConfigure.GetApprovalTsManagerDay());

            userT.UserTsManager1DueDate = DateTime.Now.AddDays(addDay);
            userT.UserTsManagerDueFlag  = 1;

            _userBService.Edit(userT);


            //insert UserMessage
            UserMessage userM = Factory.Create <UserMessage>("UserMessage", ClassType.clsTypeDataModel);

            userM.Message        = String.IsNullOrWhiteSpace(collect["approveMsg"]) ? "" : collect["approveMsg"];
            userM.MessageType    = "Approve 2";
            userM.ToUserId       = Convert.ToInt32(collect["UserId"]);
            userM.CreatedAt      = DateTime.Now;
            userM.ToEmployeeId   = userT.EmployeeId;
            userM.FromEmployeeId = userT.Approval2;

            _userMessageBService.Add(userM);

            Dictionary <String, EmployeeMaster> ApprovalData = new Dictionary <string, EmployeeMaster>();
            Dictionary <String, String>         Message      = new Dictionary <String, String>();

            ApprovalData.Add("Approval1", Spv1);
            ApprovalData.Add("Approval2", Spv2);
            ApprovalData.Add("ApprovalTS", _mstEmployeeBService.GetDetail(userTsManagerModel.EmployeeId));

            Message.Add("Approval1", _userMessageBService.GetDetail(Spv1.Employee_Id, 0, "Approve 1 - Registering").Message);
            Message.Add("Approval2", _userMessageBService.GetDetail(Spv2.Employee_Id, 0, "Approve 2 - Registering").Message);
            Message.Add("ApprovalTS", collect["ApproveMsg"]);


            //Send Email TsManager
            Email.SendMailNeedAppTs1(userT, 1, userM.Message);
            Email.SendMailResApp1(userT, userM.Message, 2, 1);
            return(RedirectToAction("ApproveList"));
        }