public ActionResult EditProfile(user user, HttpPostedFileBase user_photo) { try { if (user_photo != null) { string AWSProfileName = BaseUtil.GetWebConfigValue("AWSProfileName"); string GenFileName = BaseUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetCompanyID().ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_"); String companyFolderName = BaseUtil.GetSessionValue(UserInfo.CompanyFolderName.ToString()).ToString().Replace("/", ""); AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName); user.user_photo = GenFileName; } else { } result = userUtil.PostProfileEdit(user); ViewBag.action_name = BaseUtil.GetListAllActionByController(""); switch (result.MessageType) { case MessageType.Success: BaseUtil.SetSessionValue(UserInfo.FullName.ToString(), Convert.ToString(user.user_name)); BaseUtil.SetSessionValue(UserInfo.Mobile.ToString(), Convert.ToString(user.mobile)); BaseUtil.SetSessionValue(UserInfo.UserPhoto.ToString(), Convert.ToString(user.user_photo)); BaseUtil.SetSessionValue(UserInfo.Gender.ToString(), Convert.ToString(user.gender)); return(RedirectToAction("ProfileIndex", "MyProfile", new { Result = result.Message, MessageType = result.MessageType })); default: return(RedirectToAction("ProfileIndex", "MyProfile", new { Result = result.Message, MessageType = result.MessageType })); } return(View(user)); } catch { return(View(user)); } }
public ActionResult CreateEdit(user user, FormCollection frm, HttpPostedFileBase user_photo) { try { string rol_id = frm["rol_id"]; if (user_photo != null) { string AWSProfileName = BaseUtil.GetWebConfigValue("AWSProfileName"); string GenFileName = BaseUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetCompanyID().ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_"); String companyFolderName = BaseUtil.GetSessionValue(UserInfo.CompanyFolderName.ToString()).ToString().Replace("/", ""); AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName); user.user_photo = GenFileName; } else { user.user_photo = user.gender + ".JPG"; } result = userUtil.PostCreateEdit(user, frm); ViewBag.Title = user == null ? "User Create" : "User Edit"; ViewBag.action_name = BaseUtil.GetListAllActionByController(""); switch (result.MessageType) { case MessageType.Success: return(RedirectToAction("Index", "User", new { id = rol_id, Result = result.Message, MessageType = result.MessageType })); default: return(RedirectToAction("CreateEdit", "User", new { id = user.user_id, Result = result.Message, MessageType = result.MessageType })); } return(View(user)); } catch (Exception ex) { return(View(user)); } }