public IList <company> CompanyList() { int userID = 0, companyID = 0; IList <company> companyList = new List <company>(); try { company companyCountRecord = new company(); foreach (var item in db.companies.Where(x => x.is_active)) { companyCountRecord = new company(); companyCountRecord.business_name = item.business_name; companyCountRecord.is_active = item.is_active; companyCountRecord.company_id = item.company_id; companyList.Add(companyCountRecord); } } catch (Exception ex) { throw ex; } return(companyList); }
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); }