Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        public ActionResult GetEmploymentStatus(string IDNO)
        {
            BLLProfile _profile = new BLLProfile();

            EditEmployeeViewModel model =  _profile.GetEmployeeProfile(IDNO);

            return Json(model.EmploymentStatusId, JsonRequestBehavior.AllowGet);
        }
Esempio n. 3
0
        public ActionResult Edit(string IDNO)
        {
            BLLProfile _profile = new BLLProfile();
            EditEmployeeViewModel _employee = _profile.GetEmployeeProfile(IDNO);
            _employee.IDNO = IDNO;
            _employee.CivilStatus = _profile.GetCivilStatus();
            _employee.Department = _profile.GetDepartmentNames();
            _employee.EmploymentStatus = _profile.GetEmploymentStatus();

            return View(_employee);
        }
Esempio n. 4
0
        public ActionResult Edit(EditEmployeeViewModel model)
        {
            BLLProfile _profile = new BLLProfile();

            try
            {
                if(ModelState.IsValid)
                {
                    
                    if(_profile.UpdateEmployeeProfile(model, User.IDNO))
                    {
                        TempData["editEmployee_result"] = "Employee profile has successfully been updated.";
                    }
                    else
                    {
                        ModelState.AddModelError("", "An error has occurred."); 
                    }
                }

                EditEmployeeViewModel _employee = _profile.GetEmployeeProfile(model.IDNO);
                _employee.CivilStatus = _profile.GetCivilStatus();
                _employee.Position = _profile.GetPositionTitles();
                _employee.Department = _profile.GetDepartmentNames();
                _employee.EmploymentStatus = _profile.GetEmploymentStatus();

                return View(_employee);
            }
            catch(Exception e)
            {
                EditEmployeeViewModel _employee = _profile.GetEmployeeProfile(model.IDNO);
                _employee.CivilStatus = _profile.GetCivilStatus();
                _employee.Position = _profile.GetPositionTitles();
                _employee.Department = _profile.GetDepartmentNames();
                _employee.EmploymentStatus = _profile.GetEmploymentStatus();

                ModelState.AddModelError("", e.StackTrace);

                return View(_employee);
            }
        }