Exemple #1
0
        public ActionResult SaveEmp(Employee model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (Request.Files.Count > 0)
                    {
                        var file = Request.Files[Request.Files.Count - 1];

                        if (file != null)
                        {
                            string pic = Path.GetFileName(file.FileName);

                            string extensionFileName = CommonFunction.getExtensionFileName(pic);

                            pic = CommonFunction.hashSHA256(pic) + extensionFileName;

                            string path = Path.Combine(Server.MapPath(Constants.EMP_IMG_URL_ADD), pic);
                            model.Avatar_URL = pic;

                            file.SaveAs(path);
                        }
                    }


                    ViewEmp.UpdateEmp(model);
                    return(RedirectToAction("ViewEmp", "Adminstrator"));
                }
            }
            catch
            {
                ModelState.AddModelError("", "Save Failed! Try again later");
            }



            return(View(model));
        }
Exemple #2
0
        public ActionResult EditEmp(int idemp)
        {
            Employee model = ViewEmp.GetOneEmp(idemp);

            return(View(model));
        }