Beispiel #1
0
        public ActionResult Edit(EmpInsuranceItem model, HttpPostedFileBase[] files)
        {
            //int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString());
            //    model.EmpID = Empid;
            EmpInsuranceService objPass = new EmpInsuranceService();
            string uid = null;

            if (Session["UserId"] != null)
            {
                uid = Session["UserId"].ToString();
            }
            model.UpdatedBy   = uid;
            model.UpdatedDate = System.DateTime.Now;
            if (files != null)
            {
                string strtext = "Insurance";
                foreach (HttpPostedFileBase file in files)
                {
                    if (file != null)
                    {
                        string filename   = System.IO.Path.GetFileName(file.FileName);
                        string folderPath = Server.MapPath("~/UploadedDocs/") + strtext;
                        //  obj.EmpId = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString());
                        string destinationPath    = folderPath;
                        string employeeFolderPath = destinationPath;
                        // create folder if it is not exist
                        if (!Directory.Exists(folderPath))
                        {
                            Directory.CreateDirectory(folderPath);
                            if (!Directory.Exists(employeeFolderPath))
                            {
                                Directory.CreateDirectory(employeeFolderPath);
                                // create emp id folder of not exist
                            }
                        }
                        else
                        {
                            if (!Directory.Exists(employeeFolderPath))
                            {
                                Directory.CreateDirectory(employeeFolderPath);
                                // create emp id folder of not exist
                            }
                        }
                        destinationPath = employeeFolderPath;
                        /*Saving the file in server folder*/
                        //file.SaveAs(Server.MapPath("~/Images/" + filename));
                        string fileNewName = Guid.NewGuid() + Path.GetExtension(file.FileName);

                        file.SaveAs(Path.Combine(destinationPath, fileNewName));

                        model.FileName = filename;
                        model.FilePath = Path.Combine("/UploadedDocs/" + strtext + "/", fileNewName);
                    }
                }
            }

            objPass.Update(model);
            return(RedirectToAction("Create", new { @menuId = model.Viewbagidformenu }));
        }
        public ActionResult Edit(EmpInsuranceItem model)
        {
            //int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString());
            //    model.EmpID = Empid;
            EmpInsuranceService objPass = new EmpInsuranceService();
            string uid = null;

            if (Session["UserId"] != null)
            {
                uid = Session["UserId"].ToString();
            }
            model.UpdatedBy   = uid;
            model.UpdatedDate = System.DateTime.Now;
            objPass.Update(model);
            return(RedirectToAction("Create", new { @menuId = model.Viewbagidformenu }));
        }