Esempio n. 1
0
        public ActionResult applyOOOForOthersUser(string msad)
        {
            string msidOwn = Session["MSID"].ToString();
            bool   flag    = false;
            bool   result  = false;

            byte[]     dummy         = new byte[0];
            DateTime   todayData     = DateTime.Now;
            ApplyLeave applyLeaveObj = new ApplyLeave();

            flag = applyLeaveObj.ApplyLeaves(msad, todayData, todayData, "Sick/UnPlanned", 1, "", "Approval Pending", dummy);
            Dictionary <string, string> toGetEmailandNameDetails          = applyLeaveObj.toGetEmailandNameDetailsFromDB(msad);
            Dictionary <string, string> toGetSupervisorEmailandNameDetail = applyLeaveObj.toGetNameEmailSupDetails(msad);
            Dictionary <string, string> msidOwnEmail = applyLeaveObj.toGetSelfEmailIDOOO(msidOwn);

            result = emailForOOO(toGetEmailandNameDetails, toGetSupervisorEmailandNameDetail, msidOwnEmail, applyLeaveObj);
            if (flag == true && result == true)
            {
                return(Content("Leave Applied Succesfully"));
            }
            else
            {
                return(Content("Something went Wrong"));
            }
        }
Esempio n. 2
0
        public ActionResult ApplyLeaves(ApplyLeave applyLeave, HttpPostedFileBase file)
        {
            byte[]     imageData = null;
            ApplyLeave obj       = new ApplyLeave();
            var        list      = obj.getTypeOfLeave();

            obj.TOL = obj.GetSelectListItem(list);
            if (file != null)
            {
                string name = Path.GetExtension(file.FileName).ToLower();
                applyLeave.MSID = Session["MSID"].ToString();
                if (file.ContentLength > 0 && (name.Equals(".jpg") || name.Equals(".jpeg") || name.Equals(".png")))
                {
                    using (var binaryReader = new BinaryReader(file.InputStream))
                    {
                        imageData = binaryReader.ReadBytes(file.ContentLength);
                    }

                    if (applyLeave.ApplyLeaves(applyLeave.MSID, applyLeave.StartDate, applyLeave.EndDate, applyLeave.TypeOfLeaves, applyLeave.TotalLeaves, applyLeave.Reason, applyLeave.Status, imageData))
                    {
                        ViewBag.Message = "Success";
                        ApplyLeave applyLeaves = new ApplyLeave();
                        Dictionary <string, string> toGetEmailDetails = applyLeaves.toGetEmailDetails(applyLeave.MSID);
                        Dictionary <string, string> toGetNameDetails  = applyLeaves.toGetNameDetails(applyLeave.MSID);
                        mailSent = emailToSupervisor(toGetEmailDetails, toGetNameDetails, applyLeave);
                        return(RedirectToAction("ViewLeaves", "ApplyLeave"));
                    }
                    else
                    {
                        ViewBag.Message = "Invalid input";
                        return(View(obj));
                    }
                }

                else
                {
                    return(View(obj));
                }
            }
            else
            {
                byte[] dummy = new byte[0];
                applyLeave.TotalLeaves = SampleOther(applyLeave.StartDate, applyLeave.EndDate);
                if (applyLeave.ApplyLeaves(applyLeave.MSID, applyLeave.StartDate, applyLeave.EndDate, "Planned", applyLeave.TotalLeaves, applyLeave.Reason, applyLeave.Status, dummy))
                {
                    bool   result  = false;
                    string msidOwn = Session["MSID"].ToString();
                    Dictionary <string, string> toGetEmailandNameDetails          = applyLeave.toGetEmailandNameDetailsFromDB(applyLeave.MSID);
                    Dictionary <string, string> toGetSupervisorEmailandNameDetail = applyLeave.toGetNameEmailSupDetails(applyLeave.MSID);
                    Dictionary <string, string> msidOwnEmail = applyLeave.toGetSelfEmailIDOOO(msidOwn);
                    result = emailForPlannedLeave(toGetEmailandNameDetails, toGetSupervisorEmailandNameDetail, msidOwnEmail, applyLeave);
                    if (result == true)
                    {
                        return(RedirectToAction("ViewLeaves"));
                    }
                    else
                    {
                        return(Content("Something went Wrong"));
                    }
                }
                else
                {
                    ViewBag.Message = "Invalid input";
                    return(View(obj));
                }
            }
        }