Esempio n. 1
0
        public ActionResult ApplyLeavesForSS(HttpPostedFileBase file)
        {
            byte[]     imageData = null;
            int        id        = Convert.ToInt32(Session["ID"]);
            ApplyLeave obj       = new ApplyLeave();
            var        list      = obj.getTypeOfLeave();

            obj.TOL = obj.GetSelectListItem(list);
            string name = Path.GetExtension(file.FileName).ToLower();

            obj             = obj.UpdateeditScreenShot(id);
            Session["MSID"] = obj.MSID;
            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);
                }
                //applyLeave.MSID = Session["MSID"].ToString();
                //applyLeave.StartDate = Convert.ToDateTime(Session["StartDate"]);
                //applyLeave.EndDate = Convert.ToDateTime(Session["EndDate"]);
                //applyLeave.TypeOfLeaves = Session["TypeOfLeaves"].ToString();
                //applyLeave.TotalLeaves = Convert.ToInt32(Session["TotalLeaves"]);
                //if (ModelState.IsValid)
                //{
                if (obj.ApplyLeavesSS(id, obj.Reason, imageData))
                //if (obj.ApplyLeavesSS(ob imageData))
                {
                    ViewBag.Message = "Success";
                    ApplyLeave applyLeaves = new ApplyLeave();
                    Dictionary <string, string> toGetEmailDetails = applyLeaves.toGetEmailDetails(obj.MSID);
                    Dictionary <string, string> toGetNameDetails  = applyLeaves.toGetNameDetails(obj.MSID);
                    mailSent = emailToSupervisor(toGetEmailDetails, toGetNameDetails, obj);
                    return(RedirectToAction("ViewLeaves", "ApplyLeave"));
                }
                else
                {
                    ViewBag.Message = "Invalid input";
                    return(View(obj));
                }
            }
            else
            {
                return(View(obj));
            }
            //}

            //else
            //    return View(obj);
        }