コード例 #1
0
ファイル: BLLEmail.cs プロジェクト: rafaelbacus/EMP
        public bool EmailEmployee(LeaveViewModel model)
        {
            bool sendSuccess = false;

            BLLProfile _profile = new BLLProfile();

            using (SmtpClient client = new SmtpClient(SERVER, PORT))
            {
                string EMAIL_FROM = "*****@*****.**";
                string SUBJECT = "Leave of Absence Application [" + model.LeaveStatus + "]";
                string EMAIL_TO = _profile.GetEmployeeProfile(model.EmployeeIDNO).Email; 

                string status = "";
                switch (model.LeaveStatus)
	            {
                    case "Approved": 
                        status = "<strong style='color:#5CB85C'>APPROVED</strong>";
                        break;
                    case "Declined":
                        status = "<strong style='color:#D9534F'>DECLINED</strong>";
                        break;
		            default: break;
	            }

                StringBuilder BODY = new StringBuilder();
                BODY.Append("<p>The following Leave of Absence application has been " + status + ":</p><br>");
                BODY.Append("<p><strong>Date Filed: </strong>" + model.DateFiled.ToShortDateString() + "</p>");
                BODY.Append("<p><strong>Type: </strong>" + model.LeaveType + "</p>");
                BODY.Append("<p><strong>From: </strong>" + model.DateOfLeaveFrom.ToShortDateString() + "</p>");
                BODY.Append("<p><strong>To: </strong>" + model.DateOfLeaveTo.ToShortDateString() + "</p>");
                BODY.Append("<p><strong>Address: </strong>" + model.Address + "</p>");
                BODY.Append("<p><strong>Reason: </strong>" + model.Reason + "</p>");
                BODY.Append("<p><strong>Remarks: </strong>" + model.RemarksForEmployee + "</p><br>");
                BODY.Append("<p>Contact your Manager or HR for any questions.<p>");
                BODY.Append("<p>EMP<p>");

                MailMessage msg = new MailMessage(EMAIL_FROM, EMAIL_TO, SUBJECT, BODY.ToString());
                msg.IsBodyHtml = true;

                try
                {
                    client.Send(msg);
                    sendSuccess = true;
                }
                catch (Exception e)
                {
                    sendSuccess = false;
                    Debug.WriteLine(e);
                }
            }

            return sendSuccess;
        }
コード例 #2
0
ファイル: LeaveController.cs プロジェクト: rafaelbacus/EMP
        public ActionResult Respond(LeaveViewModel model)
        {
            BLLLeave _leave = new BLLLeave();

            JsonResult json = new JsonResult();
            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

            string result = "error";
            if (_leave.UpdateLeaveStatus(User.IDNO, model))
            {
                model = _leave.GetLeaveInfo(model.LeaveID);

                BLLEmail _email = new BLLEmail();
                if(_email.EmailEmployee(model))
                {
                    result = "success";
                }
            }

            json.Data = new { result = result, id = model.LeaveID, status = model.LeaveStatus };

            return json;
        }
コード例 #3
0
ファイル: DALLeave.cs プロジェクト: rafaelbacus/EMP
        public bool UpdateLeaveStatus(string IDNO, LeaveViewModel model)
        {
            using(DataContext _context = new DataContext())
            {
                int _affectedRows = 0;
                
                _affectedRows += _context.Database.ExecuteSqlCommand("pUpdateLeaveStatus @xManagerIDNO, @xLeaveID, @xLeaveStatus," + 
                                                                                        "@xRemarksForEmployee, @xRemarksForHR",
                            new SqlParameter("@xManagerIDNO", 10001),
                            new SqlParameter("@xLeaveID", model.LeaveID),
                            new SqlParameter("@xLeaveStatus", model.LeaveStatus),
                            new SqlParameter("@xRemarksForEmployee", (object)model.RemarksForEmployee ?? DBNull.Value),
                            new SqlParameter("@xRemarksForHR", (object)model.RemarksForHR ?? DBNull.Value));

                _affectedRows += _context.Database.ExecuteSqlCommand("pUpdateManagerLeave @xManagerIDNO, @xLeaveID, @xLeaveStatus",
                            new SqlParameter("@xManagerIDNO", 10001),
                            new SqlParameter("@xLeaveID", model.LeaveID),
                            new SqlParameter("@xLeaveStatus", model.LeaveStatus));

                _context.Database.Connection.Close();
                _context.Database.Connection.Dispose();

                if(_affectedRows == 2)
                {
                    return true;
                }

                return false;
            }
        }
コード例 #4
0
ファイル: BLLLeave.cs プロジェクト: rafaelbacus/EMP
        //public bool UpdateLeave()
        //{

        //}

        

        public bool UpdateLeaveStatus(string IDNO, LeaveViewModel model)
        {
            DALLeave _leave = new DALLeave();

            return _leave.UpdateLeaveStatus(IDNO, model);
        }