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; result = companyUtil.PostUserEdit(UserInformation); } catch (Exception ex) { result.Message = ex.Message; } return(RedirectToAction("EditCompany", "CompanySetting", new { id = user.company_id, Result = result.Message, MessageType = result.MessageType })); }
public ActionResult CreateEditJobAttachment() { job_attachment job_attachment = new job_attachment(); try { job_attachment.job_id = Convert.ToInt32(Request["job_id"] != "" ? Request["job_id"] : "0"); job_attachment.client_id = Convert.ToInt32(Request["client_id"] != "" ? Request["client_id"] : "0"); job_attachment.description = Request["description"] != null ? Request["description"] : ""; job_attachment.is_active = Convert.ToBoolean(Request["is_active"]); HttpFileCollectionBase files = Request.Files; HttpPostedFileBase attachment = files.Count > 0 ? files[0] : null; if (job_attachment != null) { string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + Path.GetFileName(attachment.FileName).Replace(" ", "_"); String companyFolderName = SessionUtil.GetCompanyFolderName(); companyFolderName = companyFolderName.Replace("/", ""); UploadFile(companyFolderName, attachment, GenFileName); job_attachment.job_attachment1 = GenFileName; } else { job_attachment.job_attachment1 = ""; } } catch (Exception ex) { result.Message = ex.Message; result.MessageType = MessageType.Error; } result = jobUtil.PostCreateEditJobAttachment(job_attachment); return(Json(result)); }
public ActionResult CreateEditUser(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser) { try { user.role_id = String.IsNullOrEmpty(frmAdminUser["role_id"]) ? 0 : Convert.ToInt32(frmAdminUser["role_id"]); 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 { user.user_photo = userdata != null ? userdata.user_photo : "NA.jpg"; } user.parent_user_id = SessionUtil.GetUserID(); result = userUtil.PostUserEdit(user); } catch (Exception ex) { result.Message = ex.Message; result.MessageType = MessageType.Error; } return(RedirectToAction("Index", "User", new { id = String.Format("{0},{1}", user.role_id, user.role_bit), Result = result.Message, MessageType = result.MessageType })); }
public ActionResult CreateEdit(user user, FormCollection frm, HttpPostedFileBase user_photo) { try { string rol_id = frm["rol_id"]; string hdnUserPhoto = frm["hdnUserPhoto"]; if (user_photo != null) { string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName"); string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetCompanyID().ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_"); String companyFolderName = STUtil.GetSessionValue(UserInfo.CompanyFolderName.ToString()).ToString().Replace("/", ""); user.user_photo = GenFileName; } else { user.user_photo = hdnUserPhoto != null ? (hdnUserPhoto != "" ? hdnUserPhoto : user.gender + ".JPG") : user.gender + ".JPG"; } result = userUtil.PostCreateEdit(user, frm); ViewBag.Title = user == null ? "User Create" : "User Edit"; ViewBag.action_name = STUtil.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)); } }
public void UploadFile(string company_folder_name, HttpPostedFileBase file, string GenFileName = "") { if (file != null) { string fileName = string.Empty; String companyFolderName = company_folder_name.Replace("/", ""); GenFileName = string.IsNullOrEmpty(GenFileName)? STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetCompanyID().ToString() + "_" + Path.GetFileName(file.FileName).Replace(" ", "_"): GenFileName; var path = Path.Combine(Server.MapPath("~/Files/" + companyFolderName), GenFileName); file.SaveAs(path); } }
public ActionResult CreateEdit(company company, HttpPostedFileBase company_logo, FormCollection frmUser) { try { string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName"); string SystemImagePath = STUtil.GetWebConfigValue("SystemImagePath"); company CompanyInformation = db.companies.Find(company.company_id); if (company_logo != null) { string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_"); String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", ""); //// AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName, companyFolderName, GenFileName); CompanyInformation.company_logo = GenFileName; UploadFile(companyFolderName, company_logo); } CompanyInformation.business_name = company.business_name; CompanyInformation.licence_no = company.licence_no; //CompanyInformation.application_type_id = company.application_type_id; CompanyInformation.time_zone = company.time_zone; CompanyInformation.country_code = company.country_code; CompanyInformation.phone = company.phone; CompanyInformation.state_id = company.state_id; CompanyInformation.city = company.city; CompanyInformation.address = company.address; CompanyInformation.zip = company.zip; CompanyInformation.is_active = company.is_active; db.Entry(CompanyInformation).State = System.Data.Entity.EntityState.Modified; result.Message = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Company"); STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "0"); db.SaveChanges(); #region FolderCreation string ImagePath = STUtil.GetWebConfigValue("ImagePath"); //AWSUtil.FolderCreation(AWSProfileName, companyInfo.company_folder_name); #endregion STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1"); } catch (Exception ex) { STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1"); result.Message = ex.Message; } return(RedirectToAction("EditCompany", "Company", new { id = company.company_id, Result = result.Message, MessageType = result.MessageType })); }
public ActionResult CreateEditClient(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser) { var isRole = frmAdminUser["IsJob"]; var JobId = frmAdminUser["hdnJobId"] == ""?0:Convert.ToInt32(frmAdminUser["hdnJobId"]); try { user.role_bit = (Int32)Role.Client; user.role_id = db.roles.AsEnumerable().Where(x => x.role_bit == (Int32)Role.Client && x.company_id == (Int32)SessionUtil.GetCompanyID()).FirstOrDefault().role_id; var role = db.roles.AsEnumerable().Where(x => x.company_id == user.company_id && x.role_bit == (Int32)Role.Client && x.is_active).ToList(); user.role_id = role.Count > 0 ? role.Select(x => x.role_id).FirstOrDefault() : 0; 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; UploadFile(SessionUtil.GetCompanyFolderName().ToString(), user_photo); } else { user.user_photo = userdata != null ? userdata.user_photo : "NA.jpg"; } user.parent_user_id = SessionUtil.GetUserID(); result = userUtil.PostUserEdit(user); } catch (Exception ex) { result.Message = ex.Message; result.MessageType = MessageType.Error; } if (string.IsNullOrEmpty(isRole)) { return(RedirectToAction("Index", "Client", new { Result = result.Message, MessageType = result.MessageType })); } else { return(RedirectToAction("CreateEditJob", "Job", new { id = JobId, Result = result.Message, MessageType = result.MessageType })); } }
public ActionResult AddCompany(company company, HttpPostedFileBase company_logo, FormCollection frmUser) { try { string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName"); string userName = frmUser["user_name"]; string loginID = frmUser["login_id"]; string emailID = frmUser["email_id"]; string mobile = frmUser["mobile"]; string password = frmUser["password"]; string gender = frmUser["gender"]; STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1"); result = companyUtil.PostCompanyCreateEdit(company, company_logo, userName, loginID, emailID, mobile, gender, password); var companyEdit = db.companies.Find(company.company_id); //if (company_logo != null) //{ // string fileName = string.Empty; // // String companyFolderName = companyEdit.company_folder_name.Replace("/", ""); // fileName = company.company_logo; // var path = Path.Combine(Server.MapPath("~/Files/" + companyFolderName), fileName); // company_logo.SaveAs(path); //} string GenFileName = ""; if (company_logo != null) { GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + company.company_id.ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_"); company.company_logo = GenFileName; } UploadFile(companyEdit.company_folder_name, company_logo, GenFileName); STUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), "1"); } catch (Exception ex) { STUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1"); result.Message = ex.Message; } return(RedirectToAction("Index", "Company", new { Result = result.Message, MessageType = result.MessageType })); }
public ActionResult EditProfile(user user, HttpPostedFileBase user_photo) { try { if (user_photo != null) { string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName"); string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetCompanyID().ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_"); String companyFolderName = STUtil.GetSessionValue(UserInfo.CompanyFolderName.ToString()).ToString().Replace("/", ""); UploadFile(SessionUtil.GetCompanyFolderName().ToString(), user_photo); user.user_photo = GenFileName; } else { } result = userUtil.PostProfileEdit(user); ViewBag.action_name = STUtil.GetListAllActionByController(""); switch (result.MessageType) { case MessageType.Success: STUtil.SetSessionValue(UserInfo.FullName.ToString(), Convert.ToString(user.user_name)); STUtil.SetSessionValue(UserInfo.Mobile.ToString(), Convert.ToString(user.mobile)); STUtil.SetSessionValue(UserInfo.UserPhoto.ToString(), Convert.ToString(user.user_photo)); STUtil.SetSessionValue(UserInfo.Gender.ToString(), Convert.ToString(user.gender)); return(RedirectToAction("MyProfile", "MyProfile", new { Result = result.Message, MessageType = result.MessageType })); default: return(RedirectToAction("MyProfile", "MyProfile", new { Result = result.Message, MessageType = result.MessageType })); } return(View(user)); } catch { return(View(user)); } }
public Result PostCompanyCreateEdit(company company, HttpPostedFileBase company_logo, string userName, string loginID, string emailID, string mobile, string gender, string password) { try { string AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName"); int userID = SessionUtil.GetUserID(); company companyEdit = new company(); if (company_logo != null) { string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + company.company_id.ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_"); company.company_logo = GenFileName; } if (company.company_id > 0) { companyEdit = db.companies.Find(company.company_id); company.company_logo = (company.company_logo != "" && company.company_logo != null) ? company.company_logo : (companyEdit.company_logo); var isUpadte = db.USP_UpdateCompany(company.company_id, userID, company.business_name, company.time_zone, company.country_code, company.phone, company.state_id, company.city, company.address, company.zip, companyEdit.admin_user_name, company.is_active, System.DateTime.Now, company.licence_no, company.company_logo); db.SaveChanges(); #region FileUpload if (company_logo != null) { String companyFolderName = companyEdit.company_folder_name.Replace("/", ""); //// AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName, companyFolderName, company.company_logo); } #endregion result.Message = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Company"); result.Id = company.company_id; } else { var companyInfo = db.USP_Create_Company_user_SA(company.time_zone, company.business_name, company.country_code, company.phone, company.address, company.city, company.zip, company.state_id, userName, loginID, mobile, emailID, password, gender, company.licence_no, company.company_logo); db.SaveChanges(); result.Message = string.Format(BaseConst.MSG_SUCCESS_CREATE, "Company"); result.MessageType = MessageType.Success; ///result.Id = companyInfo.FirstOrDefault().company_id; #region FolderCreation //string company_folder_name = companyInfo.FirstOrDefault().company_folder_name; //string company_folder_name = "COMPANY_73_20180719/"; //////AWSUtil.FolderCreation(AWSProfileName, company_folder_name); #endregion #region FileUpload if (company_logo != null) { // String companyFolderName = company_folder_name.Replace("/", ""); // AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName, companyFolderName, company.company_logo); } #endregion //#region SendMail //string EMAIL_TEMPALTE_FOLDER = STUtil.GetWebConfigValue("EMAIL_TEMPALTE_FOLDER"); //var emailTempRecord = db.email_template.AsEnumerable().Where(x => x.email_template_type_id == 5).OrderByDescending(x => x.email_template_id).FirstOrDefault();//5 - ACCOUNT_ACTIVATED //if (emailTempRecord != null) //{ // ImagePath = STUtil.GetWebConfigValue("ImagePath"); // EMAIL_TEMPALTE_FOLDER = STUtil.GetWebConfigValue("EMAIL_TEMPALTE_FOLDER"); // string APPLICATION_URL = STUtil.GetWebConfigValue("APPLICATION_URL"); // String templateName = ImagePath + EMAIL_TEMPALTE_FOLDER + "/" + emailTempRecord.email_template_file_name; // var filePath = (new WebClient()).DownloadString(templateName); // //filePath = filePath.Replace("{UserName}", companyInfo.user_name); // //filePath = filePath.Replace("{business_name}", companyInfo.business_name); // filePath = filePath.Replace("{LOGIN_ID}", loginID); // filePath = filePath.Replace("{PASSWORD}", password); // filePath = filePath.Replace("{EMAIL_ID}", emailID); // filePath = filePath.Replace("{APPLICATION_URL}", APPLICATION_URL); // STUtil.SendMail(emailID, "Welcome to SnagTick: " + loginID, filePath, null); //} //#endregion } } catch (Exception ex) { result.MessageType = MessageType.Error; result.Message = ex.Message; } return(result); }