public ActionResult CreateEditUser(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser) { try { var userdata = db.users.Find(user.user_id); company CompanyInformation = db.companies.Find(user.company_id); if (user_photo != null) { string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName"); string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_"); String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", ""); /// AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName); user.user_photo = GenFileName; } else if (userdata != null) { user.user_photo = userdata.user_photo; } user.parent_user_id = SessionUtil.GetUserID(); result = companyUtil.PostUserEdit(user); } catch (Exception ex) { result.Message = ex.Message; result.MessageType = MessageType.Error; } return(RedirectToAction("EditCompany", "CompanySetting", new { id = user.company_id, Result = result.Message, MessageType = result.MessageType })); }
public ActionResult CreateEditAdmin(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser) { try { var userid = user.user_id; user UserInformation = db.users.Find(userid); company CompanyInformation = db.companies.Find(UserInformation.company_id); if (user_photo != null) { string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName"); string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_"); String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", ""); ///////// AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName); UserInformation.user_photo = GenFileName; } UserInformation.user_name = user.user_name; UserInformation.mobile = user.mobile; UserInformation.gender = user.gender; //UserInformation.is_account_access = user.is_account_access; //UserInformation.is_account_add_payment = user.is_account_add_payment; //UserInformation.is_property_edit = user.is_property_edit; result = companyUtil.PostUserEdit(UserInformation); //return RedirectToAction("CompanyIndex", "Settings", new { Result = result.Message, MessageType = result.MessageType }); } catch (Exception ex) { result.Message = ex.Message; } return(RedirectToAction("EditCompany", "Company", new { id = user.company_id, Result = result.Message, MessageType = result.MessageType })); }
public ActionResult UserCreateEdit(USER user, FormCollection frm, HttpPostedFileBase UserPhoto) { if (UserPhoto != null) { #region Attache Documents string fileName = string.Empty; List <String> arrfileName = new List <String>(); int loop = 0; // Verify that the user selected a file if (UserPhoto != null && UserPhoto.ContentLength > 0) { // extract only the fielname fileName = Guid.NewGuid() + "_" + SessionUtil.GetUserID() + "_" + Path.GetFileName(UserPhoto.FileName); fileName = System.DateTime.Now.Millisecond.ToString() + Path.GetFileName(UserPhoto.FileName); var path = Path.Combine(Server.MapPath("~/Files/UsersPhoto/"), fileName); UserPhoto.SaveAs(path); arrfileName.Add(fileName); } else { arrfileName.Add("NA.JPG"); } loop++; user.UserPhoto = arrfileName[0].ToString(); #endregion } string pass = frm["pass"] != null ? frm["pass"] : ""; result = companyUtil.PostUserEdit(user, pass); switch (result.MessageType) { case MessageType.Success: return(RedirectToAction("CompanyTabs", "Company", new { id = user.CompanyId, Result = result.Message, MessageType = result.MessageType })); default: return(RedirectToAction("CompanyTabs", "Company", new { id = user.CompanyId, Result = result.Message, MessageType = result.MessageType })); } }