public string SaveFile(string PhotoPath, HttpPostedFileBase file) { if (PhotoPath != "") { //Delete Old Image string pathDel = Server.MapPath("~/CustomerPhoto"); FileInfo objfile = new FileInfo(pathDel); if (objfile.Exists) //check file exsit or not { objfile.Delete(); } //End :Delete Old Image } //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/CustomerPhoto"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); return(CommonCls.GetURL() + "/CustomerPhoto/" + fileName); }
// GET: /Brokerage/ public ActionResult Index(string FirstName, string Email, string PhoneNo, string TrebId) { if (Session["CustomerID"] == null) { return(RedirectToAction("Index", "Account")); } List <BrokerageListModel> model = new List <BrokerageListModel>(); var brokerages = _BrokerageService.GetCompanies().Join(_CustomerService.GetCustomers(), b => b.CustomerId, c => c.CustomerId, (b, c) => new { cust = c, brok = b }).Where(c => c.cust.ParentId == Convert.ToInt64(Session["UserId"])).ToList(); Mapper.CreateMap <CommunicationApp.Entity.Brokerage, CommunicationApp.Web.Models.BrokerageListModel>(); foreach (var brokerage in brokerages.Select(c => c.brok)) { var result = Mapper.Map <CommunicationApp.Entity.Brokerage, CommunicationApp.Web.Models.BrokerageListModel>(brokerage); string status = brokerage.Status == true ? "approved" : "disapproved"; result.Status = status; //if(result.BrokerageDate!= ""&& result.BrokerageDate!=null) //{ // //string brokDate = DateTime.ParseExact(result.BrokerageDate, "dd/MM/yyyy", CultureInfo.InvariantCulture) // // .ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); // result.BrokDate = Convert.ToDateTime(result.BrokerageDate); //} //if (result.VerificationDate != "" && result.VerificationDate != null) //{ // result.VerifDate = Convert.ToDateTime(result.VerificationDate); //} var cust = _CustomerService.GetCustomer(Convert.ToInt32(result.CustomerId)); result.TrebId = cust.TrebId; result.PhNo = cust.MobileNo; result.FirstName = cust.FirstName; result.EmailID = cust.EmailId; result.PageUrl = CommonCls.GetURL() + "Brokerage/GetBrokerage?BrokerageId=" + result.BrokerageId; model.Add(result); } //search by FirstName. if (!string.IsNullOrEmpty(FirstName)) { model = model.Where(c => c.FirstName.ToLower().Contains(FirstName.ToLower().Trim())).ToList();//.Where(c => c.FirstName.ToLower().Contains(FirstName.ToLower())); } //search by Email if (!string.IsNullOrEmpty(Email)) { model = model.Where(c => c.EmailID.ToLower().Contains(Email.ToLower().Trim())).ToList();//.Where(c => c.FirstName.ToLower().Contains(FirstName.ToLower())); } //search by PhoneNo if (!string.IsNullOrEmpty(PhoneNo)) { model = model.Where(c => c.PhNo.ToLower().Contains(PhoneNo.ToLower().Trim())).ToList();//.Where(c => c.FirstName.ToLower().Contains(FirstName.ToLower())); } //For Search By TrebId if (!string.IsNullOrEmpty(TrebId) && !string.IsNullOrEmpty(TrebId) && TrebId.Trim() != "" && TrebId.Trim() != "") { model = model.Where(c => c.TrebId == TrebId).ToList(); } SessionBatches(); return(View(model.OrderByDescending(c => c.BrokerageId))); }
public ActionResult NewsletterList(string NewsLetterName) { var AdminId = Convert.ToInt32(Session["CustomerID"]) == null ? 0 : Convert.ToInt32(Session["CustomerID"]); var CustomerList = _CustomerService.GetCustomers().Where(c => c.ParentId == AdminId); List <NewsLetter_Model> ModelList = new List <NewsLetter_Model>(); var NewsLetters = _NewsLetterService.GetNewsLetters().OrderBy(c => c.OrderNo); if (!string.IsNullOrEmpty(NewsLetterName)) { NewsLetters = NewsLetters.Where(c => c.NewsLetterName.ToLower().Contains(NewsLetterName.ToLower())).OrderBy(c => c.OrderNo); } Mapper.CreateMap <CommunicationApp.Entity.NewsLetter_Entity, CommunicationApp.Models.NewsLetter_Model>(); foreach (var NewsLetter in NewsLetters) { CommunicationApp.Models.NewsLetter_Model NewLetterModel = Mapper.Map <CommunicationApp.Entity.NewsLetter_Entity, CommunicationApp.Models.NewsLetter_Model>(NewsLetter); if (NewsLetter.Image == null || NewsLetter.Image == "") { NewLetterModel.Image = CommonCls.GetURL() + "/images/noImage.jpg"; } else if (NewsLetter.Image.IndexOf(',') > -1) { var splitimgs = NewsLetter.Image.Split(','); NewLetterModel.first_img = splitimgs[0]; NewLetterModel.second_img = splitimgs[1]; } else { } if (NewLetterModel.SelectedUsers != "" && NewLetterModel.SelectedUsers != null) { List <string> selectedusers = new List <string>(); var UsersIds = NewLetterModel.SelectedUsers.Split(',').Select(int.Parse).ToList(); var Users = CustomerList.Where(c => UsersIds.Contains(c.CustomerId)); foreach (var usr in Users) { selectedusers.Add(usr.FirstName + " " + usr.LastName); } NewLetterModel.Select_users = selectedusers; } ModelList.Add(NewLetterModel); } ViewBag.OrderList = OrderNoList(); ViewBag.Customerlist = CustomerList.Select(x => new SelectListItem { Value = x.CustomerId.ToString(), Text = x.FirstName + " " + x.LastName }).AsEnumerable(); return(View(ModelList)); }
public string SaveImage(string Base64String) { string fileName = Guid.NewGuid() + ".png"; Image image = CommonCls.Base64ToImage(Base64String); var subPath = Server.MapPath("~/CustomerPhoto"); var path = Path.Combine(subPath, fileName); image.Save(path, System.Drawing.Imaging.ImageFormat.Png); string URL = CommonCls.GetURL() + "/CustomerPhoto/" + fileName; return(URL); }
public string SaveImage(string Base64String) { string fileName = Guid.NewGuid() + ".Jpeg"; System.Drawing.Image image = CommonCls.Base64ToImage(Base64String); var subPath = System.Web.HttpContext.Current.Server.MapPath("~/CustomerPhoto"); var path = System.IO.Path.Combine(subPath, fileName); image.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg); string URL = CommonCls.GetURL() + "/CustomerPhoto/" + fileName; return(URL); }
// GET: /Customer/Edit/5 public ActionResult Edit(int id) { AdminStaffModel AdminStaffModel = new CommunicationApp.Models.AdminStaffModel(); var AdminStaff = _AdminStaffService.GetAdminStaff(id); if (AdminStaff != null) { var models = new List <AdminModel>(); Mapper.CreateMap <CommunicationApp.Entity.AdminStaff, CommunicationApp.Models.AdminStaffModel>(); AdminStaffModel = Mapper.Map <CommunicationApp.Entity.AdminStaff, CommunicationApp.Models.AdminStaffModel>(AdminStaff); if (AdminStaffModel.PhotoPath == null && AdminStaffModel.PhotoPath == "") { AdminStaffModel.PhotoPath = CommonCls.GetURL() + "/images/noImage.jpg"; } } return(View(AdminStaffModel)); }
public string Savefile(HttpPostedFileBase file) { //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/CustomerPhoto"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); return(CommonCls.GetURL() + "/CustomerPhoto/" + fileName); }
// GET: /Customer/Edit/5 public ActionResult Edit(int id) { AdminModel AdminModel = new CommunicationApp.Models.AdminModel(); var Customer = _CustomerService.GetCustomers().Where(c => c.CustomerId == id).FirstOrDefault(); if (Customer != null) { var models = new List <AdminModel>(); Mapper.CreateMap <CommunicationApp.Entity.Customer, CommunicationApp.Models.AdminModel>(); AdminModel = Mapper.Map <CommunicationApp.Entity.Customer, CommunicationApp.Models.AdminModel>(Customer); var User = _UserService.GetUser(Customer.UserId); var Company = _CompanyService.GetCompany(Customer.CompanyID); if (Company != null) { AdminModel.AdminCompanyLogo = Company.LogoPath; AdminModel.CompanyName = Company.CompanyName; AdminModel.AdminCompanyAddress = Company.CompanyAddress; } if (User != null) { AdminModel.Password = SecurityFunction.DecryptString(User.Password); } if (AdminModel.PhotoPath != null && AdminModel.PhotoPath != "") { AdminModel.PhotoPath = AdminModel.PhotoPath; } else { AdminModel.PhotoPath = CommonCls.GetURL() + "/images/noImage.jpg"; } } ViewBag.CityID = (Customer.CityID <= 0 ? "" : Customer.CityID.ToString()); ViewBag.StateID = (Customer.StateID <= 0 ? "" : Customer.StateID.ToString()); ViewBag.Countrylist = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Customer.CountryID); ViewBag.Citylist = new SelectList(_CityService.GetCities(), "CityID", "CityName", Customer.CityID); ViewBag.UserId = new SelectList(_UserService.GetUsers(), "UserId", "FirstName", Customer.UserId); return(View(AdminModel)); }
public string SaveImage(HttpPostedFileBase file) { var Url = ""; //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/NewsLetterImages"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); Url = CommonCls.GetURL() + "/NewsLetterImages/" + fileName; return(Url); }
public ActionResult UpdateProfile([Bind(Include = "AgencyIndividualId,EmailId,FullName,WorkRate,ContactNumber,Address,Latitude,Longitude")] AgencyIndividualModel model, HttpPostedFileBase file) { AgencyIndividualModel agencyIndividualModel = new Models.AgencyIndividualModel(); List <CategoryModel> CategoryList = new List <CategoryModel>(); var categories = _CategoryService.GetCategories(); //UserPermissionAction("vendor", RoleAction.view.ToString(), operation, ShowMessage, MessageBody); if (string.IsNullOrEmpty(model.FullName)) { ModelState.AddModelError("FullName", ""); return(View(model)); } if (model.WorkRate == null) { ModelState.AddModelError("WorkRate", ""); return(View(model)); } if (string.IsNullOrEmpty(model.ContactNumber)) { ModelState.AddModelError("ContactNumber", ""); return(View(model)); } if (string.IsNullOrEmpty(model.Address)) { ModelState.AddModelError("Address", ""); return(View(model)); } try { if (ModelState.IsValid) { string name = ""; if (file != null && file.ContentLength > 0) { try { if (file != null && file.ContentLength > 0) { name = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); string path = Path.Combine(Server.MapPath("~/AgencyImage"), name); file.SaveAs(path); } } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } var existingUser = _UserService.GetUserByEmailId(model.EmailId); if (existingUser != null) { existingUser.FirstName = model.FullName; existingUser.LastUpdatedOn = DateTime.Now; _UserService.UpdateUser(existingUser); var agencyIndividualDetail = _AgencyIndividualService.GetAgencyIndividualById(model.AgencyIndividualId); if (agencyIndividualDetail != null) { agencyIndividualDetail.FullName = model.FullName; agencyIndividualDetail.Address = model.Address; agencyIndividualDetail.ContactNumber = model.ContactNumber; agencyIndividualDetail.Latitude = model.Latitude; agencyIndividualDetail.Longitude = model.Longitude; agencyIndividualDetail.LastUpdatedOn = DateTime.Now; agencyIndividualDetail.WorkRate = model.WorkRate; agencyIndividualDetail.PhotoPath = name == ""?"":CommonCls.GetURL() + "/AgencyImage/" + name; _AgencyIndividualService.UpdateAgencyIndividual(agencyIndividualDetail); TempData["MessageBody"] = "Registeration done."; ViewBag.Error = TempData["MessageBody"]; return(RedirectToAction("Index")); } else { TempData["MessageBody"] = "User not found."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } else { TempData["MessageBody"] = "User not found."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } else { var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); TempData["MessageBody"] = "Please fill the required fields."; ViewBag.Error = TempData["MessageBody"]; return(View(model)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); return(View(model)); } }
public void SendMailToUser(string UserName, string EmailAddress, string TrebId) { try { //Send mail MailMessage mail = new MailMessage(); string Logourl = CommonCls.GetURL() + "/images/EmailLogo.png"; string Imageurl = CommonCls.GetURL() + "/images/EmailPic.png"; string FromEmailID = WebConfigurationManager.AppSettings["FromEmailID"]; string FromEmailPassword = WebConfigurationManager.AppSettings["FromEmailPassword"]; string ToEmailID = WebConfigurationManager.AppSettings["ToEmailID"]; SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"]); int _Port = Convert.ToInt32(WebConfigurationManager.AppSettings["Port"].ToString()); Boolean _UseDefaultCredentials = Convert.ToBoolean(WebConfigurationManager.AppSettings["UseDefaultCredentials"].ToString()); Boolean _EnableSsl = Convert.ToBoolean(WebConfigurationManager.AppSettings["EnableSsl"].ToString()); mail.To.Add(new MailAddress(EmailAddress)); mail.From = new MailAddress(FromEmailID); mail.Subject = "Your account is activated"; //string LogoPath = Common.GetURL() + "/images/logo.png"; string msgbody = ""; msgbody += ""; msgbody += " <div>"; msgbody += " <div style='float:left;width:100%;'>"; msgbody += "<h2 style='float:left; width:100%; font-size:16px; font-family:arial; margin:0 0 10px;'>Dear " + UserName + ",</h2>"; msgbody += "<div style='float:left;width:100%; margin:4px 0;'><p style='float:left; font-size:14px; font-family:arial; line-height:25px; margin:5px 11px 0 0;'>Treb Id :</p> <span style='float:left; font-size:14px; font-family:arial; margin:10px 0 0 0;'>" + TrebId + "</span>"; msgbody += " </div>"; msgbody += "<p style='float:left;width:100%; font-size:14px; font-family:arial; line-height:25px; margin:0;'>Your account is approved.</p>"; msgbody += "<p style='float:left;width:100%; font-size:14px; font-family:arial; line-height:25px; margin:0;'>Login using your TREB ID and start posting/ reviewing entries."; msgbody += " </p>"; msgbody += "<div style='float:left; width:100%; margin:5px 0;'>"; msgbody += "<span style='float:left; font-size:15px; font-family:arial; margin:12px 0 0 0; width:100%;'>Thanks</span><span style='float:left; font-size:15px; font-family:arial; margin:8px 0 0 0; width:100%;'></span>"; msgbody += " </div>"; msgbody += "<div style='float:left; width:100%; margin:5px 0;'>"; msgbody += "<span style='float:left; font-size:15px; font-family:arial; margin:12px 0 0 0; width:100%;'>Team</span><span style='float:left; font-size:15px; font-family:arial; margin:8px 0 0 0; width:100%;'></span>"; msgbody += " </div>"; msgbody += "<div style='width:auto; float:left;'>"; msgbody += " <p style='font-family:arial; font-size:12px; font-weight:bold; margin:0px; padding:0px;'>Call: 416 844 5725 | 647 977 3268 </p>"; msgbody += " <p style='font-family:arial; font-size:12px; font-weight:bold; margin:0px; padding:0px;'> Fax: 647 497 5646 </p>"; msgbody += " <a style='color:red; width:100%; font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='http://www.only4agents.com'>Web: www.only4agents.com</a>"; msgbody += " <a style='color:red; width:100%; font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='#'>Email: [email protected]</a>"; msgbody += " </div>"; msgbody += "<div style='float:left; width:100%; margin:5px 0;'>"; //msgbody += "<img style='float:left; width:150px;' src='data:image/png;base64," + LogoBase64 + "' /> <img style='float:left; width:310px; margin:30px 0 0 30px;' src='data:image/png;base64," + ImageBase64 + "' />"; msgbody += "<img style='float:left; width:500px;' src='" + Logourl + "' /> "; msgbody += "</div>"; msgbody += "</div>"; msgbody += "</div>"; mail.Body = msgbody; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Host = "smtp.gmail.com"; //_Host; smtp.Port = _Port; //smtp.UseDefaultCredentials = _UseDefaultCredentials; smtp.Credentials = new System.Net.NetworkCredential(FromEmailID, FromEmailPassword);// Enter senders User name and password smtp.EnableSsl = _EnableSsl; smtp.Send(mail); } catch (Exception ex) { string ErrorMsg = ex.ToString(); } }
public ActionResult Edit([Bind(Include = "CustomerId,TrebId,WebsiteUrl,ApplicationID,Password,CompanyID,UserId,PhotoPath,FirstName,LastName,MiddleName,EmailID,DOB,MobileNo,CountryID,StateID,CityID,ZipCode,Latitude,Longitude,CreatedOn,LastUpdatedOn,MobileVerifyCode,EmailVerifyCode,IsMobileVerified,IsEmailVerified,IsActive,RecoNumber,RecoExpireDate")] CustomerModel Customermodel, HttpPostedFileBase file) { UserPermissionAction("property", RoleAction.view.ToString()); CheckPermission(); TempData["ShowMessage"] = ""; TempData["MessageBody"] = ""; try { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please fill the required field with valid data"; if (ModelState.IsValid) { var CustomerFound = _CustomerService.GetCustomers().Where(c => ((c.EmailId.Trim() == Customermodel.EmailID.Trim() || c.MobileNo.Trim() == Customermodel.MobileNo.Trim()) && c.CustomerId != Customermodel.CustomerId)).FirstOrDefault(); if (CustomerFound == null) { var PhotoPath = ""; var CustomerUpdate = _CustomerService.GetCustomer(Customermodel.CustomerId);//.Where(c => c.CustomerId == Customermodel.CustomerId).FirstOrDefault(); if (CustomerUpdate != null) { PhotoPath = CustomerUpdate.PhotoPath; if (file != null) { if (CustomerUpdate.PhotoPath != "") { //Delete Old Image string pathDel = Server.MapPath("~/CustomerPhoto"); FileInfo objfile = new FileInfo(pathDel); if (objfile.Exists) //check file exsit or not { objfile.Delete(); } //End :Delete Old Image } //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/CustomerPhoto"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); PhotoPath = CommonCls.GetURL() + "/CustomerPhoto/" + fileName; } CommonClass CommonClass = new CommonClass(); string QStr = ""; DataTable dt = new DataTable(); QStr = "update Customer set PhotoPath='" + PhotoPath + "' ,MobileNo='" + Customermodel.MobileNo + "' ,Address='" + Customermodel.Address + "' ,FirstName='" + Customermodel.FirstName + "' "; QStr += " ,LastName='" + Customermodel.LastName + "',MiddleName='" + Customermodel.MiddleName + "' ,EmailId='" + Customermodel.EmailID + "' ,CityID='" + Convert.ToInt32(Customermodel.CityID) + "' ,StateID='" + Convert.ToInt32(Customermodel.StateID) + "' , "; QStr += "IsActive='" + Convert.ToBoolean(Customermodel.IsActive) + "' ,WebsiteUrl='" + Customermodel.WebsiteUrl + "' ,UpdateStatus='" + true + "' Where CustomerId='" + Convert.ToInt32(Customermodel.CustomerId) + "' "; CommonClass.ExecuteNonQuery(QStr); // dt = CommonClass.GetDataSet(QStr).Tables[0]; CustomerUpdate.LastUpdatedOn = DateTime.Now; _CustomerService.UpdateCustomer(CustomerUpdate); if (Customermodel.IsActive == false) { string Flag = "14"; var NotificationStatus = false; string Message = "Your account is deactivated"; string JsonMessage = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\"}"; //Save Notification Notification Notification = new Notification(); Notification.NotificationSendBy = 1; Notification.NotificationSendTo = Convert.ToInt32(CustomerUpdate.CustomerId); Notification.IsRead = false; Notification.Flag = Convert.ToInt32(Flag); Notification.RequestMessage = Message; _Notification.InsertNotification(Notification); if (CustomerUpdate.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android)) { CommonCls.SendGCM_Notifications(CustomerUpdate.ApplicationId, JsonMessage, true); } else { //Dictionary<string, object> Dictionary = new Dictionary<string, object>(); //Dictionary.Add("Flag", Flag); //Dictionary.Add("Message", Message); //NotificationStatus = PushNotificatinAlert.SendPushNotification(CustomerUpdate.ApplicationId, Message, Flag.ToString(), JsonMessage, Dictionary, 1); int count = _Notification.GetNotifications().Where(c => c.NotificationSendTo == Convert.ToInt32(CustomerUpdate.CustomerId) && c.IsRead == false).ToList().Count(); CommonCls.TestSendFCM_Notifications(CustomerUpdate.ApplicationId, JsonMessage, Message, count, true); } } string FirstName = CustomerUpdate.FirstName + " " + CustomerUpdate.MiddleName + " " + CustomerUpdate.LastName; if (CustomerUpdate.IsUpdated == true) { SendMailToUpdatedUser(FirstName, CustomerUpdate.EmailId, CustomerUpdate.TrebId); } else { SendMailToUser(FirstName, CustomerUpdate.EmailId, CustomerUpdate.TrebId); } TempData["ShowMessage"] = "success"; TempData["MessageBody"] = CustomerUpdate.FirstName + " is update successfully."; } else { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Customer not found."; } return(RedirectToAction("customerlist", "Property")); } else { TempData["ShowMessage"] = "error"; if (CustomerFound.EmailId.Trim() == Customermodel.EmailID.Trim()) { TempData["MessageBody"] = Customermodel.EmailID + " is already exists."; } if (CustomerFound.TrebId.Trim() == Customermodel.TrebId.Trim()) { TempData["MessageBody"] = Customermodel.TrebId + " is already exists."; } if (CustomerFound.MobileNo.Trim() == Customermodel.MobileNo.Trim()) { TempData["MessageBody"] = "This" + " " + Customermodel.MobileNo + " is already exists."; } else { TempData["MessageBody"] = "Please fill the required field with valid data"; } } } } catch (RetryLimitExceededException) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on " + Customermodel.FirstName + " client"; } var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); //ViewBag.CityID = new SelectList(_CityService.GetCities(), "CityID", "CityName", Carriermodel.CityID); // ViewBag.CompanyID = new SelectList(_CompanyService.GetCompanies(), "CompanyID", "CompanyName", Customermodel.CompanyID); //ViewBag.CountryID = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Carriermodel.CountryID); //ViewBag.StateID = new SelectList(_StateService.GetStates(), "StateID", "StateName", Carriermodel.StateID); ViewBag.UserId = new SelectList(_UserService.GetUsers(), "UserId", "FirstName", Customermodel.UserId); ViewBag.CityID = (Customermodel.CityID <= 0 ? "" : Customermodel.CityID.ToString()); ViewBag.StateID = (Customermodel.StateID <= 0 ? "" : Customermodel.StateID.ToString()); ViewBag.Countrylist = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Customermodel.CountryID); ViewBag.Statelist = new SelectList(_StateService.GetStates(), "StateID", "StateName", Customermodel.StateID); ViewBag.Citylist = new SelectList(_CityService.GetCities(), "CityID", "CityName", Customermodel.CityID); return(View(Customermodel)); }
public ActionResult Edit([Bind(Include = "CategoryId,Name,Colour,CurrentPageNo")] CategoryModel CategoryModel, HttpPostedFileBase file) { UserPermissionAction("Category", RoleAction.view.ToString()); CheckPermission(); try { if (string.IsNullOrWhiteSpace(CategoryModel.Name)) { ModelState.AddModelError("Name", "Please enter category name."); } if (string.IsNullOrWhiteSpace(CategoryModel.Colour)) { ModelState.AddModelError("Colour", "Please select colour."); } if (ModelState.IsValid) { var IsParentAllReadyContainCategoryName = _CategoryService.GetCategories().Where(c => c.CategoryId != CategoryModel.CategoryId).Select(c => c.Name); if (IsParentAllReadyContainCategoryName.Contains(CategoryModel.Name.Trim())) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = " Category name is already exist."; return(RedirectToAction("Edit")); } Category CategoryFound = _CategoryService.GetCategories().Where(x => x.Name == CategoryModel.Name && x.CategoryId != CategoryModel.CategoryId).FirstOrDefault(); var existingCategory = _CategoryService.GetCategories().Where(c => c.CategoryId == CategoryModel.CategoryId).FirstOrDefault(); Mapper.CreateMap <HomeHelp.Models.CategoryModel, HomeHelp.Entity.Category>(); HomeHelp.Entity.Category Categorys = Mapper.Map <HomeHelp.Models.CategoryModel, HomeHelp.Entity.Category>(CategoryModel); if (CategoryFound == null) { if (file != null && file.ContentLength > 0) { try { if (Categorys.PhotoPath != "") { DeleteImage(Categorys.PhotoPath); } string path = Path.Combine(Server.MapPath("~/CategoryImage"), Path.GetFileName(file.FileName)); file.SaveAs(path); string URL = CommonCls.GetURL() + "/CategoryImage/" + file.FileName; Categorys.PhotoPath = URL; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { Categorys.PhotoPath = existingCategory.PhotoPath; } Categorys.IsActive = true; _CategoryService.UpdateCategory(Categorys); TempData["ShowMessage"] = "success"; TempData["MessageBody"] = " Category update successfully."; return(RedirectToAction("Index", new { CurrentPageNo = CategoryModel.CurrentPageNo })); // end Update CompanyEquipments } else { TempData["ShowMessage"] = "error"; if (CategoryFound.Name.Trim().ToLower() == CategoryModel.Name.Trim().ToLower()) //Check User Name { TempData["MessageBody"] = CategoryFound.Name + " already exist."; } else { TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on "; } } } else { ViewBag.CategoryList = Colors.ToList(); return(View(CategoryModel)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); } ViewBag.Category = new SelectList(_CategoryService.GetCategories(), "CategoryId", "Name", CategoryModel.CategoryId); var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); return(View(CategoryModel)); }
public ActionResult Edit([Bind(Include = "AdminStaffId,CustomerId,TrebId,WebsiteUrl,ApplicationID,Password,CompanyID,UserId,PhotoPath,FirstName,LastName,MiddleName,EmailID,MobileNo,Address,CountryID,StateID,CityID,ZipCode,Latitude,Longitude,CreatedOn,LastUpdatedOn,MobileVerifyCode,EmailVerifyCode,IsMobileVerified,IsEmailVerified,IsActive")] AdminStaffModel AdminStaffModel, HttpPostedFileBase file) { UserPermissionAction("property", RoleAction.view.ToString()); CheckPermission(); TempData["ShowMessage"] = ""; TempData["MessageBody"] = ""; try { if (ModelState.IsValid) { var CustomerFound = _CustomerService.GetCustomers().Where(c => ((c.EmailId.Trim() == AdminStaffModel.EmailId.Trim() || c.MobileNo.Trim() == AdminStaffModel.MobileNo.Trim()) && c.CustomerId != AdminStaffModel.CustomerId)).FirstOrDefault(); if (CustomerFound == null) { var PhotoPath = ""; var AdminStaffUpdate = _AdminStaffService.GetAdminStaff(AdminStaffModel.AdminStaffId);//.Where(c => c.CustomerId == AdminModel.CustomerId).FirstOrDefault(); if (AdminStaffUpdate.PhotoPath != null && AdminStaffUpdate.PhotoPath != "") { PhotoPath = AdminStaffUpdate.PhotoPath; } if (AdminStaffUpdate != null) { // PhotoPath = CustomerUpdate.PhotoPath; if (file != null) { if (AdminStaffUpdate.PhotoPath != "") { //Delete Old Image string pathDel = Server.MapPath("~/CustomerPhoto"); FileInfo objfile = new FileInfo(pathDel); if (objfile.Exists) //check file exsit or not { objfile.Delete(); } //End :Delete Old Image } //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/CustomerPhoto"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); PhotoPath = CommonCls.GetURL() + "/CustomerPhoto/" + fileName; } AdminStaffUpdate.PhotoPath = PhotoPath; AdminStaffUpdate.FirstName = AdminStaffModel.FirstName; AdminStaffUpdate.LastName = AdminStaffModel.LastName; AdminStaffUpdate.Address = AdminStaffModel.Address; AdminStaffUpdate.EmailId = AdminStaffModel.EmailId; AdminStaffUpdate.DOB = AdminStaffModel.DOB; AdminStaffUpdate.WebsiteUrl = AdminStaffModel.WebsiteUrl; AdminStaffUpdate.MobileNo = AdminStaffModel.MobileNo; if (AdminStaffModel.IsActive == true) { AdminStaffUpdate.IsActive = true; } else { AdminStaffUpdate.IsActive = false; } if (AdminStaffModel.Designation != null && AdminStaffModel.Designation != "") { AdminStaffUpdate.Designation = AdminStaffModel.Designation; } _AdminStaffService.UpdateAdminStaff(AdminStaffUpdate); TempData["ShowMessage"] = "success"; TempData["MessageBody"] = AdminStaffUpdate.FirstName + " is update successfully."; return(RedirectToAction("Index", "AdminStaff")); } else { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "User not found."; return(RedirectToAction("Index", "AdminStaff")); } } else { TempData["ShowMessage"] = "error"; if (CustomerFound.EmailId.Trim() == AdminStaffModel.EmailId.Trim()) { TempData["MessageBody"] = AdminStaffModel.EmailId + " is already exists."; } if (CustomerFound.MobileNo.Trim() == AdminStaffModel.MobileNo.Trim()) { TempData["MessageBody"] = "This" + " " + AdminStaffModel.MobileNo + " is already exists."; } else { TempData["MessageBody"] = "Please fill the required field with valid data"; } } } } catch (Exception ex) { CommonCls.ErrorLog(ex.ToString()); TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on " + AdminStaffModel.FirstName + " client"; } var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); return(View(AdminStaffModel)); }
public ActionResult Create([Bind(Include = "AdminStaffId,CustomerId,WebsiteUrl,PhotoPath,FirstName,LastName,EmailID,MobileNo,ZipCode,Latitude,Longitude,Address,Designation,DOB,IsActive")] AdminStaffModel AdminStaffModel, HttpPostedFileBase file) { TempData["ShowMessage"] = ""; TempData["MessageBody"] = ""; UserPermissionAction("adminstaff", RoleAction.create.ToString()); CheckPermission(); Mapper.CreateMap <CommunicationApp.Models.AdminStaffModel, CommunicationApp.Entity.AdminStaff>(); CommunicationApp.Entity.AdminStaff AdminStaff = Mapper.Map <CommunicationApp.Models.AdminStaffModel, CommunicationApp.Entity.AdminStaff>(AdminStaffModel); if (ModelState.IsValid) { if (AdminStaff != null) { var PhotoPath = ""; if (file != null) { //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/CustomerPhoto"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); PhotoPath = CommonCls.GetURL() + "/CustomerPhoto/" + fileName; } AdminStaff.PhotoPath = PhotoPath; if (AdminStaff.FirstName == null) { AdminStaff.FirstName = ""; } if (AdminStaff.LastName == null) { AdminStaff.LastName = ""; } var CustomerId = Convert.ToInt32(Session["CustomerId"]) == null ? 0 : Convert.ToInt32(Session["CustomerId"]); AdminStaff.CustomerId = CustomerId; _AdminStaffService.InsertAdminStaff(AdminStaff); AdminStaffModel.CustomerId = AdminStaff.CustomerId; TempData["ShowMessage"] = "Success"; TempData["MessageBody"] = "AdminStaff successfully saved."; } } else { var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); TempData["ShowMessage"] = "Error"; TempData["MessageBody"] = "Please fill the required data."; return(View(AdminStaffModel)); } return(RedirectToAction("Index")); }
public ActionResult Create(EventModel EventModel, HttpPostedFileBase file) { UserPermissionAction("event", RoleAction.view.ToString()); CheckPermission(); TempData["ShowMessage"] = ""; TempData["MessageBody"] = ""; try { if (ModelState.IsValid) { if (string.IsNullOrEmpty(EventModel.EventDate.ToString())) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please select a valid Event Date."; return(View("Create", EventModel)); } if (string.IsNullOrEmpty(EventModel.EventName)) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please Fill Event Name."; return(View("Create", EventModel)); } if (string.IsNullOrEmpty(EventModel.EventDescription)) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please Fill EventDescription."; return(View("Create", EventModel)); } //CultureInfo culture = new CultureInfo("en-US"); //DateTime TodayDate = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"), culture); //if (Convert.ToDateTime(EventModel.EventDate.ToString("MM/dd/yyyy"), culture) < TodayDate) //{ // TempData["ShowMessage"] = "error"; // TempData["MessageBody"] = "You cannot add old date event."; // return View("Create", EventModel); //} Mapper.CreateMap <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>(); CommunicationApp.Entity.Event Event = Mapper.Map <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>(EventModel); string EventImage = ""; if (file != null) { if (Event.EventImage != "") { //Delete Old Image string pathDel = Server.MapPath("~/EventPhoto"); FileInfo objfile = new FileInfo(pathDel); if (objfile.Exists) //check file exsit or not { objfile.Delete(); } //End :Delete Old Image } //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/EventPhoto"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); EventImage = CommonCls.GetURL() + "/EventPhoto/" + fileName; } Event.CustomerId = Convert.ToInt32(Session["CustomerId"]);//CutomerId Event.IsActive = true; Event.CreatedOn = DateTime.Now; Event.EventImage = EventImage; _EventService.InsertEvent(Event); List <int> CustomerIds = new List <int>(); var Customers = new List <Customer>(); try { if (EventModel.All == true) { EventModel.SelectedCustomer = null; Customers = _CustomerService.GetCustomers().ToList(); foreach (var Customer in Customers) { CustomerIds.Add(Convert.ToInt32(Customer.CustomerId)); EventCustomer EventCustomer = new Entity.EventCustomer(); EventCustomer.EventId = Event.EventId; EventCustomer.CustomerId = Customer.CustomerId; _EventCustomerService.InsertEventCustomer(EventCustomer); } } else if (EventModel.SelectedCustomer != null) { foreach (var Customer in EventModel.SelectedCustomer) { CustomerIds.Add(Convert.ToInt32(Customer)); EventCustomer EventCustomer = new Entity.EventCustomer(); EventCustomer.EventId = Event.EventId; EventCustomer.CustomerId = Event.CustomerId; _EventCustomerService.InsertEventCustomer(EventCustomer); } } } catch (Exception ex) { ErrorLogging.LogError(ex); throw; } string Flag = "12";//status for Event; var Message = "New event saved."; //send notification try { var CustomerList = _CustomerService.GetCustomers().Where(c => CustomerIds.Contains(c.CustomerId) && c.CustomerId != EventModel.CustomerId && c.IsActive == true).ToList(); foreach (var Customer in CustomerList) { if (Customer != null) { if (Customer.ApplicationId != null && Customer.ApplicationId != "") { bool NotificationStatus = true; string JsonMessage = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\"}"; try { //Save Notification Notification Notification = new Notification(); Notification.NotificationSendBy = 1; Notification.NotificationSendTo = Convert.ToInt32(Customer.CustomerId); Notification.IsRead = false; Notification.Flag = Convert.ToInt32(Flag); Notification.RequestMessage = Message; _Notification.InsertNotification(Notification); if (Customer.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android)) { CommonCls.SendGCM_Notifications(Customer.ApplicationId, JsonMessage, true); } else { int count = _Notification.GetNotifications().Where(c => c.NotificationSendTo == Convert.ToInt32(Customer.CustomerId) && c.IsRead == false).ToList().Count(); //Dictionary<string, object> Dictionary = new Dictionary<string, object>(); //Dictionary.Add("Flag", Flag); //Dictionary.Add("Message", Message); //NotificationStatus = PushNotificatinAlert.SendPushNotification(Customer.ApplicationId, Message, Flag, JsonMessage, Dictionary, 1, Convert.ToBoolean(Customer.IsNotificationSoundOn)); CommonCls.TestSendFCM_Notifications(Customer.ApplicationId, JsonMessage, Message, count, true); ////Save Notification //Notification Notification = new Notification(); //Notification.NotificationSendBy = 1; //Notification.NotificationSendTo = Customer.CustomerId; //Notification.IsRead = false; //Notification.RequestMessage = Message; //_Notification.InsertNotification(Notification); } } catch (Exception ex) { CommonCls.ErrorLog(ex.ToString()); } } } } } catch (Exception ex) { ErrorLogging.LogError(ex); throw; } TempData["ShowMessage"] = "success"; TempData["MessageBody"] = "Event successfully saved."; return(RedirectToAction("Index")); } var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); var CustomerList1 = _CustomerService.GetCustomers(); EventModel.CustomersList = CustomerList1.Select(x => new SelectListItem { Value = x.CustomerId.ToString(), Text = x.FirstName }).ToList(); EventModel.CustomerId = 1; return(View(EventModel)); } catch (Exception ex) { ErrorLogging.LogError(ex); return(View(EventModel)); } }
public ActionResult Create([Bind(Include = "TipId,CustomerId,TipUrl,Title,CreatedOn,LastUpdatedOn,IsActive")] TipModel tipModel, HttpPostedFileBase file) { UserPermissionAction("Tip", RoleAction.create.ToString()); CheckPermission(); try { //TempData["ShowMessage"] = "error"; //TempData["MessageBody"] = "Please fill the required field with valid data."; if (file != null) { var fileExt = Path.GetExtension(file.FileName); if (fileExt != ".pdf") { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please upload only .pdf file."; return(RedirectToAction("Create")); } //if (tipModel.Title == "" || tipModel.Title == null ) //{ // TempData["ShowMessage"] = "error"; // TempData["MessageBody"] = "Please fill the title field."; // return RedirectToAction("Create"); //} if (ModelState.IsValid) { Mapper.CreateMap <CommunicationApp.Models.TipModel, CommunicationApp.Entity.Tip>(); CommunicationApp.Entity.Tip tipEntity = Mapper.Map <CommunicationApp.Models.TipModel, CommunicationApp.Entity.Tip>(tipModel); //Save the Logo in Folder string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/TipData"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); string URL = CommonCls.GetURL() + "/TipData/" + fileName; tipEntity.CustomerId = Convert.ToInt32(Session["CustomerId"]); tipEntity.TipUrl = URL; tipEntity.IsActive = true; tipEntity.CreatedOn = DateTime.Now; _TipService.InsertTip(tipEntity); var Flag = 13;//status for Tip of the day. var Message = "New Tip of the day."; ////send notification //var CustomerList = _CustomerService.GetCustomers().Where(c => c.CustomerId != tipModel.CustomerId && c.IsActive == true).ToList(); //foreach (var Customer in CustomerList) //{ // if (Customer != null) // { // if (Customer.ApplicationId != null && Customer.ApplicationId != "") // { // string PropertyDetail = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\"}"; // Common.SendGCM_Notifications(Customer.ApplicationId, PropertyDetail, true); // } // } //} TempData["ShowMessage"] = "success"; TempData["MessageBody"] = "Tip is saved successfully."; return(RedirectToAction("Index")); } } else { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please upload a valid file."; return(RedirectToAction("Create")); } } catch (Exception ex) { ErrorLogging.LogError(ex); TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on Tip."; } // return RedirectToAction("Create", "Tip", new { id = tipModel.TipId }); return(View(tipModel)); }
public ActionResult Edit([Bind(Include = "RewardId,Title,Description,Smileys")] RewardModel RewardModel, HttpPostedFileBase file) { UserPermissionAction("Category", RoleAction.view.ToString()); CheckPermission(); try { if (string.IsNullOrWhiteSpace(RewardModel.Title)) { ModelState.AddModelError("Title", "Please enter Title."); } if (string.IsNullOrWhiteSpace(RewardModel.Description)) { ModelState.AddModelError("Description", "Please enter Description."); } if (RewardModel.Smileys == 0) { ModelState.AddModelError("Smileys", "Please enter smileys."); } if (ModelState.IsValid) { //Reward RewardFound = _RewardService.GetRewards().Where(x => x.Name == RewardModel.Name && x.RewardId != RewardModel.RewardId).FirstOrDefault(); var existingReward = _RewardService.GetRewards().Where(c => c.RewardId == RewardModel.RewardId).FirstOrDefault(); Mapper.CreateMap <RewardModel, Reward>(); var Reward = Mapper.Map <RewardModel, Reward>(RewardModel); if (file != null && file.ContentLength > 0) { try { if (existingReward.ImagePath != "") { DeleteImage(existingReward.ImagePath); } string path = Path.Combine(Server.MapPath("~/RewardImage"), Path.GetFileName(file.FileName)); file.SaveAs(path); string URL = CommonCls.GetURL() + "/RewardImage/" + file.FileName; Reward.ImagePath = URL; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { Reward.ImagePath = existingReward.ImagePath; } if (existingReward != null) { _RewardService.UpdateReward(Reward); TempData["ShowMessage"] = "success"; TempData["MessageBody"] = " Reward update successfully."; return(RedirectToAction("Index")); // end Update CompanyEquipments } else { TempData["MessageBody"] = "reward not found."; } } else { return(View(RewardModel)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); } //ViewBag.Category = new SelectList(_CategoryService.GetCategories(), "CategoryId", "Name", RewardModel.RewardId); var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); return(View(RewardModel)); }
public void SendMailToUser(string UserName, string EmailAddress, PropertyModel PropertyType) { try { var ConcateData = ""; if (PropertyType.Style != "" && PropertyType.Style != null) { ConcateData += PropertyType.Style + ","; } if (PropertyType.PropertyType != "" && PropertyType.PropertyType != null) { ConcateData += PropertyType.PropertyType + ","; } if (PropertyType.LocationPrefered != "" && PropertyType.LocationPrefered != null) { ConcateData += PropertyType.LocationPrefered; } // Send mail. MailMessage mail = new MailMessage(); string Logourl = CommonCls.GetURL() + "/images/EmailLogo.png"; string Imageurl = CommonCls.GetURL() + "/images/EmailPic.png"; string FromEmailID = WebConfigurationManager.AppSettings["FromEmailID"]; string FromEmailPassword = WebConfigurationManager.AppSettings["FromEmailPassword"]; string ToEmailID = WebConfigurationManager.AppSettings["ToEmailID"]; SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"]); int _Port = Convert.ToInt32(WebConfigurationManager.AppSettings["Port"].ToString()); Boolean _UseDefaultCredentials = Convert.ToBoolean(WebConfigurationManager.AppSettings["UseDefaultCredentials"].ToString()); Boolean _EnableSsl = Convert.ToBoolean(WebConfigurationManager.AppSettings["EnableSsl"].ToString()); mail.To.Add(new MailAddress(EmailAddress)); mail.From = new MailAddress(FromEmailID); mail.Subject = "Property successfully registered. "; //string LogoPath = ClsCommon.GetURL() + "/images/logo.png"; string msgbody = ""; msgbody += ""; msgbody += " <div>"; msgbody += " <div style='float:left;width:100%;'>"; msgbody += "<h2 style='float:left; width:100%; font-size:16px; font-family:arial; margin:0 0 10px;'>Dear " + UserName + ",</h2>"; msgbody += "<div style='float:left;width:100%; margin:4px 0;'><p style='float:left; font-size:14px; font-family:arial; line-height:25px; margin:0 11px 0 0;'>Treb Id:</p> <span style='float:left; font-size:14px; font-family:arial; margin:5px 0 0 0;'><b>" + PropertyType.CustomerTrebId + "<b></span>"; msgbody += " </div>"; msgbody += "<div style='float:left;width:100%; margin:4px 0;'><p style='float:left; font-size:14px; font-family:arial; line-height:25px; margin:0 11px 0 0;'>This message refers to your post under:</p> <span style='float:left; font-size:14px; font-family:arial; margin:5px 0 0 0;'><b>" + PropertyType.PropertyTypeStatus + "<b></span>"; msgbody += " </div>"; msgbody += "<p style='float:left;width:100%; font-size:14px; font-family:arial; line-height:25px; margin:0;'>Your post is under review, we will notify you once approved.</p>"; msgbody += "<span style='float:left; font-size:15px; font-family:arial; margin:12px 0 0 0; width:100%;'>Team</span>"; msgbody += "<div style='width:auto; float:left;'>"; msgbody += " <p style='font-family:arial; font-size:12px; font-weight:bold; margin:0px; padding:0px;'>Call: 416 844 5725 | 647 977 3268 </p>"; msgbody += " <p style='font-family:arial; font-size:12px; font-weight:bold; margin:0px; padding:0px;'> Fax: 647 497 5646 </p>"; msgbody += " <a style='color:red; width:100%; font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='http://www.only4agents.com'>Web: www.only4agents.com</a>"; msgbody += " <a style='color:red; width:100%;font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='#'>Email: [email protected]</a>"; msgbody += " </div>"; msgbody += "<div style='float:left; width:100%; margin:5px 0;'>"; msgbody += "<img style='float:left; width:500px;' src='" + Logourl + "' />"; msgbody += "</div>"; msgbody += "</div>"; msgbody += "</div>"; mail.Body = msgbody; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Host = "smtp.gmail.com"; //_Host; smtp.Port = _Port; //smtp.UseDefaultCredentials = _UseDefaultCredentials; smtp.Credentials = new System.Net.NetworkCredential(FromEmailID, FromEmailPassword);// Enter senders User name and password smtp.EnableSsl = _EnableSsl; smtp.Send(mail); } catch (Exception ex) { string ErrorMsg = ex.ToString(); } }
public ActionResult Steps2(IEnumerable <HttpPostedFileBase> file, string Type = "") { var loggedInUserr = Session["LoggedInUser"] as User; if (loggedInUserr == null) { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { var firstStepViewModel = GetSessionData <UserPropertyViewModel>("UserProperty"); // var viewModelData = GetSessionData<UserPropertyViewModel>("UserProperty"); if (firstStepViewModel.Images == null) { firstStepViewModel.Images = new List <ImageViewModel>(); } else { firstStepViewModel.Images = firstStepViewModel.Images;// new List<ImageViewModel>(); } // firstStepViewModel.Images = new List<ImageViewModel>(); var imgList = new List <ImageViewModel>(); var URL = ""; foreach (var item in file) { if (item != null && item.ContentLength > 0) { try { string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(item.FileName)); item.SaveAs(path); URL = CommonCls.GetURL() + "/Images/" + item.FileName; //thumbnail // Session["FileName"] = URL; var objImg = new ImageViewModel(); objImg.PhotoPath = URL; objImg.thumbnails = ""; imgList.Add(objImg); } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } } if (imgList.Count() > 0) { firstStepViewModel.Images.AddRange(imgList); } SetSessionData("UserProperty", firstStepViewModel); User myUser = Session["LoggedInUser"] as User;// User myUser = (User)Session["LoggedInUser"]; var user = dba.Userinfos.Where(c => c.UserId == Convert.ToInt32(myUser.Id)).FirstOrDefault(); if (user != null) { UserProfile usr = new UserProfile(); usr.Name = user.Name; usr.Middlename = user.Middlename; usr.Lastname = user.Lastname; usr.Email = user.Email; usr.Website = user.Website; usr.Designation = user.Designation; usr.PhotoPath = user.PhotoPath; usr.CompanyLogo = user.CompanyLogo; usr.CellNo = user.CellNo; firstStepViewModel.User = usr; } return(RedirectToAction("Steps3", firstStepViewModel)); } return(View()); }
public ActionResult Edit([Bind(Include = "ProductId,ProductName,Price,Size")] ProductsModel ProductModel, HttpPostedFileBase file) { UserPermissionAction("Category", RoleAction.view.ToString()); CheckPermission(); try { string URL = ""; var existingProduct = _ProductService.GetProducts().Where(c => c.ProductId == ProductModel.ProductId).FirstOrDefault(); Mapper.CreateMap <HomeHelp.Models.ProductsModel, HomeHelp.Entity.Product>(); HomeHelp.Entity.Product Products = Mapper.Map <HomeHelp.Models.ProductsModel, HomeHelp.Entity.Product>(ProductModel); if (existingProduct != null) { if (file != null && file.ContentLength > 0) { try { if (existingProduct.productImage != "") { DeleteImage(existingProduct.productImage); } string path = Path.Combine(Server.MapPath("~/ProductImage"), Path.GetFileName(file.FileName)); file.SaveAs(path); URL = CommonCls.GetURL() + "/ProductImage/" + file.FileName; Products.productImage = URL; _ProductService.UpdateProduct(Products); ProductModel.productImage = URL; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ProductModel.productImage = Products.productImage = existingProduct.productImage; _ProductService.UpdateProduct(Products); Products.productImage = existingProduct.productImage; } } if (string.IsNullOrWhiteSpace(ProductModel.ProductName)) { ModelState.AddModelError("ProductName", "Please enter product name."); } if (ProductModel.Price == null) { ModelState.AddModelError("Price", "Please enter price."); } if (ProductModel.Size.Count() == 0) { ModelState.AddModelError("Size", "Please enter size."); } if (ModelState.IsValid) { //var IsParentAllReadyContainProductName = _ProductService.GetProducts().Where(c => c.ProductId != ProductModel.ProductId).Select(c => c.Name); //if (IsParentAllReadyContainProductName.Contains(ProductModel.Name.Trim())) //{ // TempData["ShowMessage"] = "error"; // TempData["MessageBody"] = " Product name is already exist."; // return RedirectToAction("Edit"); //} //Product ProductFound = _ProductService.GetProducts().Where(x => x.Name == ProductModel.Name && x.ProductId != ProductModel.ProductId).FirstOrDefault(); if (existingProduct != null) { string Size = ""; string FinalSize = ""; foreach (var item in ProductModel.Size) { if (item == 1) { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.M); } else if (item == 2) { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.L); } else if (item == 3) { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XL); } else { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XXL); } FinalSize = FinalSize + "," + Size; } Products.Size = FinalSize.TrimEnd(',').TrimStart(','); _ProductService.UpdateProduct(Products); TempData["ShowMessage"] = "success"; TempData["MessageBody"] = " Product update successfully."; return(RedirectToAction("Index")); // end Update CompanyEquipments } else { TempData["ShowMessage"] = "error"; //if (ProductFound.Name.Trim().ToLower() == ProductModel.Name.Trim().ToLower()) //Check User Name //{ // TempData["MessageBody"] = ProductFound.Name + " already exist."; //} //else //{ TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on "; //} } } else { ViewBag.ProductList = Size.ToList(); return(View(ProductModel)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); } ViewBag.Product = new SelectList(_ProductService.GetProducts(), "ProductId", "Name", ProductModel.ProductId); var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); return(View(ProductModel)); }
public async Task <HttpResponseMessage> UploadImage() { // Check if the request contains multipart/form-data. if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } string root = HttpContext.Current.Server.MapPath("~/IdProof/temp"); CustomMultipartFormDataStreamProvider1 provider = new CustomMultipartFormDataStreamProvider1(root); try { StringBuilder sb = new StringBuilder(); // Holds the response body Type type = typeof(CustomerModel); // Get type pointer CustomerModel locationImagesModel = new CustomerModel(); // Read the form data and return an async task. CustomMultipartFormDataStreamProvider1 x = await Request.Content.ReadAsMultipartAsync(provider); Guid CustomerId = new Guid(); // This illustrates how to get the form data. foreach (var key in provider.FormData.AllKeys) { if (key == "CustomerId") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { CustomerId = new Guid(propertyValue); break; } } } //Delete all already exist files HomeHelp.Entity.Customer Customer = _CustomerService.GetCustomers().Where(c => c.CustomerId == CustomerId && c.IsActive == true).FirstOrDefault(); if (Customer != null) { if (Customer.IdProof != "" && Customer.IdProof != null) { DeleteImage(Customer.IdProof); } } else { return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "No user found."), Configuration.Formatters.JsonFormatter)); } // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(root); foreach (string fileName in fileEntries) { var fileFound = provider.FileData.Where(c => c.Headers.ContentDisposition.FileName.Replace("\"", string.Empty) == Path.GetFileName(fileName)).FirstOrDefault(); if (fileFound != null) { //string NewFileName = Guid.NewGuid() + "_Event" + EventId.ToString() + Path.GetExtension(fileName); string NewFileName = Guid.NewGuid() + Path.GetExtension(fileName); string NewRoot = HttpContext.Current.Server.MapPath("~/IdProof") + "\\" + NewFileName; System.IO.File.Move(fileName, NewRoot); string URL = CommonCls.GetURL() + "/IdProof/" + NewFileName; Customer.IdProof = URL; _CustomerService.UpdateCustomer(Customer); sb.Append(URL); } } return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", Customer.IdProof), Configuration.Formatters.JsonFormatter)); } catch (System.Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public ActionResult Edit(EventModel EventModel, HttpPostedFileBase file) { UserPermissionAction("event", RoleAction.view.ToString()); CheckPermission(); TempData["ShowMessage"] = ""; TempData["MessageBody"] = ""; try { if (ModelState.IsValid) { if (string.IsNullOrEmpty(EventModel.EventDate.ToString())) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please select a valid Event Date."; return(View("Create", EventModel)); } if (string.IsNullOrEmpty(EventModel.EventName)) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please Fill Event Name."; return(View("Create", EventModel)); } if (string.IsNullOrEmpty(EventModel.EventDescription)) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please Fill EventDescription."; return(View("Create", EventModel)); } Mapper.CreateMap <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>(); CommunicationApp.Entity.Event Event = Mapper.Map <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>(EventModel); var EventImage = ""; if (file != null) { if (Event.EventImage != "") { //Delete Old Image string pathDel = Server.MapPath("~/EventPhoto"); FileInfo objfile = new FileInfo(pathDel); if (objfile.Exists) //check file exsit or not { objfile.Delete(); } //End :Delete Old Image } //Save the photo in Folder var fileExt = Path.GetExtension(file.FileName); string fileName = Guid.NewGuid() + fileExt; var subPath = Server.MapPath("~/EventPhoto"); //Check SubPath Exist or Not if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } //End : Check SubPath Exist or Not var path = Path.Combine(subPath, fileName); file.SaveAs(path); EventImage = CommonCls.GetURL() + "/EventPhoto/" + fileName; } Event.LastUpdatedon = DateTime.Now; Event.EventImage = EventImage; _EventService.UpdateEvent(Event); TempData["ShowMessage"] = "success"; TempData["MessageBody"] = "Event successfully updated."; return(RedirectToAction("Index")); } return(View(EventModel)); } catch (Exception ex) { ErrorLogging.LogError(ex); return(View(EventModel)); } }
public ActionResult Create([Bind(Include = "CategoryId,Name,Colour,CurrentPageNo")] CategoryModel CategoryModel, HttpPostedFileBase file) { UserPermissionAction("Category", RoleAction.view.ToString()); CheckPermission(); try { string URL = ""; if (string.IsNullOrWhiteSpace(CategoryModel.Name)) { ModelState.AddModelError("Name", "Please enter category name."); } if (string.IsNullOrWhiteSpace(CategoryModel.Colour)) { ModelState.AddModelError("Description", "Please enter category name."); } if (ModelState.IsValid) { var IsCateGoryDuplicate = _CategoryService.GetCategories().Where(c => c.Name == CategoryModel.Name.Trim()).FirstOrDefault(); if (IsCateGoryDuplicate != null) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = " Category name is already exist."; return(RedirectToAction("Create")); } if (file != null && file.ContentLength > 0) { try { if (file != null && file.ContentLength > 0) { string path = Path.Combine(Server.MapPath("~/CategoryImage"), Path.GetFileName(file.FileName)); file.SaveAs(path); URL = CommonCls.GetURL() + "/CategoryImage/" + file.FileName; } } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } Mapper.CreateMap <CategoryModel, Category>(); var category = Mapper.Map <CategoryModel, Category>(CategoryModel); category.PhotoPath = URL; category.IsActive = true; _CategoryService.InsertCategory(category); //new CategoryModel //{ // CategoryId = Convert.ToInt32(CategoryModel.CategoryId), // Name = CategoryModel.Name, // Description=CategoryModel.Description// CategoryModel.ParentId == -1?null:Convert.ToInt32(CategoryModel.ParentId) //}.InsertUpdate(); TempData["ShowMessage"] = "success"; TempData["MessageBody"] = " Category save successfully."; return(RedirectToAction("Index")); } else { ViewBag.CategoryList = Colors.ToList(); return(View(CategoryModel)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); } var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); return(View(CategoryModel)); }
public ActionResult Create([Bind(Include = "ProductId,ProductName,Price,Size")] ProductsModel ProductModel, HttpPostedFileBase file) { UserPermissionAction("Category", RoleAction.view.ToString()); CheckPermission(); try { string URL = ""; if (TempData["ImageUrl"] != null) { URL = ViewBag.ImageUrl = (TempData["ImageUrl"]).ToString(); } if (file != null && file.ContentLength > 0) { try { if (file != null && file.ContentLength > 0) { string path = Path.Combine(Server.MapPath("~/ProductImage"), Path.GetFileName(file.FileName)); file.SaveAs(path); URL = CommonCls.GetURL() + "/ProductImage/" + file.FileName; ViewBag.ImageUrl = URL; } } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } if (string.IsNullOrWhiteSpace(ProductModel.ProductName)) { ModelState.AddModelError("ProductName", "Please enter product name."); } if (ProductModel.Price == null) { ModelState.AddModelError("Price", "Please enter price."); } if (ProductModel.Size.Count() == 0) { ModelState.AddModelError("Size", "Please enter size."); } if (ModelState.IsValid) { //var IsProductDuplicate = _ProductService.GetProducts().Where(c => c.ProductName == ProductModel.ProductName.Trim()).FirstOrDefault(); //if (IsProductDuplicate != null) //{ // TempData["ShowMessage"] = "error"; // TempData["MessageBody"] = " Product name is already exist."; // return RedirectToAction("Create"); //} Mapper.CreateMap <ProductsModel, Product>(); var Product = Mapper.Map <ProductsModel, Product>(ProductModel); string Size = ""; string FinalSize = ""; foreach (var item in ProductModel.Size) { if (item == 1) { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.M); } else if (item == 2) { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.L); } else if (item == 3) { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XL); } else { Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XXL); } FinalSize = FinalSize + "," + Size; } Product.Size = FinalSize.TrimEnd(',').TrimStart(','); Product.productImage = URL; _ProductService.InsertProduct(Product); //new ProductModel //{ // ProductId = Convert.ToInt32(ProductModel.ProductId), // Name = ProductModel.Name, // Description=ProductModel.Description// ProductModel.ParentId == -1?null:Convert.ToInt32(ProductModel.ParentId) //}.InsertUpdate(); TempData["ShowMessage"] = "success"; TempData["MessageBody"] = " Product save successfully."; return(RedirectToAction("Index")); } else { ViewBag.ProductList = Size.ToList(); return(View(ProductModel)); } } catch (Exception ex) { string ErrorMsg = ex.Message.ToString();// ErrorLogging.LogError(ex); } var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); return(View(ProductModel)); }
// GET: /Event/ public ActionResult Index(string StartDate, string EndDate, string Description, string FirstName) { List <EventModel> EventModelList = new List <EventModel>(); if (!string.IsNullOrEmpty(StartDate)) { if (CheckDate(StartDate) == false) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please select a valid From Date."; return(View(EventModelList)); } } if (!string.IsNullOrEmpty(EndDate)) { if (CheckDate(EndDate) == false) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please select a valid To Date."; return(View(EventModelList)); } } if (!string.IsNullOrEmpty(StartDate) && !string.IsNullOrEmpty(EndDate)) { if (Convert.ToDateTime(Convert.ToDateTime(StartDate).ToString("MM/dd/yyyy")) > Convert.ToDateTime(Convert.ToDateTime(EndDate).ToString("MM/dd/yyyy"))) { TempData["ShowMessage"] = "error"; TempData["MessageBody"] = "Please select a valid date range."; return(View(EventModelList)); } } UserPermissionAction("event", RoleAction.view.ToString()); CheckPermission(); CultureInfo Culture = new CultureInfo("en-US"); DateTime TodayDate = Convert.ToDateTime(Convert.ToDateTime(DateTime.Now).ToString("MM/dd/yyyy"), Culture); var Events = _EventService.GetEvents().Where(c => Convert.ToDateTime(Convert.ToDateTime(c.EventDate).ToString("MM/dd/yyyy"), Culture) >= TodayDate && c.IsActive == true).OrderBy(c => c.EventDate).ToList(); // var Events = _EventService.GetEvents().Where(c => c.IsActive == true).OrderByDescending(c => c.CreatedOn).ToList(); //For Search By Name if (!string.IsNullOrEmpty(FirstName)) { Events = Events.Where(c => c.EventName.ToLower().Contains(FirstName.ToLower().Trim())).ToList(); } //For Search By Description if (!string.IsNullOrEmpty(Description)) { Events = Events.Where(c => c.EventDescription.ToLower().Contains(Description.ToLower().Trim())).ToList(); } //For Search By date if (!string.IsNullOrEmpty(StartDate) && !string.IsNullOrEmpty(EndDate) && StartDate.Trim() != "" && EndDate.Trim() != "") { CultureInfo culture = new CultureInfo("en-US"); DateTime startDate = Convert.ToDateTime(Convert.ToDateTime(StartDate).ToString("MM/dd/yyyy"), culture); DateTime Enddate = Convert.ToDateTime(Convert.ToDateTime(EndDate).ToString("MM/dd/yyyy"), culture); Events = Events.Where(c => Convert.ToDateTime(Convert.ToDateTime(c.EventDate).ToString("MM/dd/yyyy"), culture) >= startDate && Convert.ToDateTime(Convert.ToDateTime(c.EventDate).ToString("MM/dd/yyyy"), culture) <= Enddate).ToList();//.Where(c => c.FirstName.ToLower().Contains(FirstName.ToLower())); } Mapper.CreateMap <CommunicationApp.Entity.Event, CommunicationApp.Models.EventModel>(); foreach (var Event in Events) { CommunicationApp.Models.EventModel EventModel = Mapper.Map <CommunicationApp.Entity.Event, CommunicationApp.Models.EventModel>(Event); if (Event.EventImage == null || Event.EventImage == "") { EventModel.EventImage = CommonCls.GetURL() + "/images/noImage.jpg"; } EventModelList.Add(EventModel); } return(View(EventModelList)); }
public ActionResult CreateProfile(UserProfile user, HttpPostedFileBase file, HttpPostedFileBase file1) { var loggedInUserr = Session["LoggedInUser"] as User; if (loggedInUserr == null) { return(RedirectToAction("Login", "Account")); } // For Profile Picture "~/Images" // string URL = ""; if (file != null && file.ContentLength > 0) { try { if (file != null && file.ContentLength > 0) { string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file.FileName.Replace(' ', '-'))); if (System.IO.File.Exists(path)) { var newPath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileNameWithoutExtension(file.FileName.Replace(' ', '-')).ToString() + DateTime.Now.ToString("yyyy-MM-dd HHmmtt") + Path.GetExtension(file.FileName)); newPath = newPath.Replace(' ', '-').ToString(); URL = CommonCls.GetURL() + "/Images/" + Path.GetFileNameWithoutExtension(file.FileName.Replace(' ', '-')).ToString() + DateTime.Now.ToString("yyyy-MM-dd HHmmtt") + Path.GetExtension(file.FileName); URL = URL.Replace(' ', '-').ToString(); file.SaveAs(newPath); } else { file.SaveAs(path); URL = CommonCls.GetURL() + "/Images/" + file.FileName.Replace(' ', '-'); } } } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } ////// Company Logo URL1 /////// string URL1 = ""; if (file1 != null && file1.ContentLength > 0) { try { if (file1 != null && file1.ContentLength > 0) { string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file1.FileName.Replace(' ', '-'))); if (System.IO.File.Exists(path)) { var newPath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileNameWithoutExtension(file1.FileName.Replace(' ', '-')).ToString() + DateTime.Now.ToString("yyyy-MM-dd HHmmtt") + Path.GetExtension(file1.FileName)); newPath = newPath.Replace(' ', '-').ToString(); URL1 = CommonCls.GetURL1() + "/Images/" + Path.GetFileNameWithoutExtension(file1.FileName.Replace(' ', '-')).ToString() + DateTime.Now.ToString("yyyy-MM-dd HHmmtt") + Path.GetExtension(file1.FileName); URL1 = URL1.Replace(' ', '-').ToString(); file1.SaveAs(newPath); } else { file1.SaveAs(path); URL1 = CommonCls.GetURL1() + "/Images/" + file1.FileName.Replace(' ', '-'); } } } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } //Save user Userinfo usr = new Userinfo(); usr.UserId = loggedInUserr.Id; usr.Name = user.Name; usr.Middlename = user.Middlename; usr.Lastname = user.Lastname; usr.City = user.City; usr.Email = user.Email; usr.Zipcode = user.Zipcode; usr.Designation = user.Designation; usr.CellNo = user.CellNo; usr.Brokerage = user.Brokerage; usr.OfficeNo = user.OfficeNo; usr.Website = user.Website; usr.PhotoPath = URL; usr.CompanyLogo = URL1; usr.OfficeAddress = user.OfficeAddress; dba.Userinfos.InsertOnSubmit(usr); dba.SubmitChanges(); return(RedirectToAction("Index", "Dashboard")); }
public async Task <HttpResponseMessage> UploadCustomerProfile() { // Check if the request contains multipart/form-data. if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } string root = HttpContext.Current.Server.MapPath("~/CustomerPhoto/temp"); CustomMultipartFormDataStreamProvider1 provider = new CustomMultipartFormDataStreamProvider1(root); try { StringBuilder sb = new StringBuilder(); // Holds the response body Type type = typeof(CustomerModel); // Get type pointer CustomerModel locationImagesModel = new CustomerModel(); // Read the form data and return an async task. CustomMultipartFormDataStreamProvider1 x = await Request.Content.ReadAsMultipartAsync(provider); int CustomerId = 0; string Bio = ""; string Privacy = ""; int Age = 0; string Gender = ""; string Music = ""; string Photography = ""; string Camping = ""; string Hiking = ""; // This illustrates how to get the form data. foreach (var key in provider.FormData.AllKeys) { if (key == "CustomerId") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { CustomerId = Convert.ToInt32(propertyValue); if (CustomerId == 0) { return(ErrorMessage("error", "Customer Id is blank.")); } } } if (key == "Age") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { Age = Convert.ToInt32(propertyValue); if (Age == 0) { return(ErrorMessage("error", "Age is blank.")); } } } if (key == "Bio") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { Bio = propertyValue; if (Bio == "" || Bio == null) { return(ErrorMessage("error", "Bio is blank.")); } } } if (key == "Privacy") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { Privacy = propertyValue; if (Privacy != EnumValue.GetEnumDescription(EnumValue.Privacy.Public) && Privacy != EnumValue.GetEnumDescription(EnumValue.Privacy.Private)) { return(ErrorMessage("error", "Privacy is wrong.")); } if (Privacy == "" || Privacy == null) { return(ErrorMessage("error", "Privacy is blank.")); } } } if (key == "Gender") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { Gender = propertyValue; if (Gender != EnumValue.GetEnumDescription(EnumValue.Gender.Female) && Gender != EnumValue.GetEnumDescription(EnumValue.Gender.Male)) { return(ErrorMessage("error", "Gender is wrong.")); } if (Gender == "" || Gender == null) { return(ErrorMessage("error", "Gender is blank.")); } } } if (key == "Music") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { Music = propertyValue; if (Music == "" || Music == null) { return(ErrorMessage("error", "Music is blank.")); } } } if (key == "Photography") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (Photography != null) { Photography = propertyValue; if (Photography == "" || Photography == null) { return(ErrorMessage("error", "Photography is blank.")); } } } if (key == "Camping") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { Camping = propertyValue; if (Camping == "" || Camping == null) { return(ErrorMessage("error", "Camping is blank.")); } } } if (key == "Hiking") { string propertyValue = provider.FormData.GetValues(key).FirstOrDefault(); if (propertyValue != null) { Hiking = propertyValue; if (Hiking == "" || Hiking == null) { return(ErrorMessage("error", "Hiking is blank.")); } } } if (CustomerId != 0 && Bio != "" && Privacy != "" && Age != 0 && Gender != "" && Music != "" && Photography != "" && Camping != "" && Hiking != "") { break; } } //Delete all already exist files HomeHelp.Entity.Customer Customer = _CustomerService.GetCustomers().Where(c => c.CustomerId == CustomerId && c.IsActive == true).FirstOrDefault(); if (Customer != null) { if (Customer.PhotoPath != "" && Customer.PhotoPath != null) { DeleteImage(Customer.BackgroundImage); } } else { return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "No user found."), Configuration.Formatters.JsonFormatter)); } // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(root); foreach (string fileName in fileEntries) { var fileFound = provider.FileData.Where(c => c.Headers.ContentDisposition.FileName.Replace("\"", string.Empty) == Path.GetFileName(fileName)).FirstOrDefault(); if (fileFound != null) { //string NewFileName = Guid.NewGuid() + "_Event" + EventId.ToString() + Path.GetExtension(fileName); string NewFileName = Guid.NewGuid() + Path.GetExtension(fileName); string NewRoot = HttpContext.Current.Server.MapPath("~/CustomerPhoto") + "\\" + NewFileName; System.IO.File.Move(fileName, NewRoot); string URL = CommonCls.GetURL() + "/CustomerPhoto/" + NewFileName; Customer.PhotoPath = URL; sb.Append(URL); } } Customer.Bio = Bio; Customer.Privacy = Privacy; Customer.Age = Age; Customer.Gender = Gender; _CustomerService.UpdateCustomer(Customer); HobbiesAndInterests hobbies = _HobbiesAndInterestsService.GetHobbiesAndInterestss().Where(c => c.CustomerId == CustomerId).FirstOrDefault(); if (hobbies != null) { hobbies.Music = Convert.ToInt32(Music); hobbies.Hiking = Convert.ToInt32(Hiking); hobbies.Camping = Convert.ToInt32(Camping); hobbies.Photography = Convert.ToInt32(Photography); hobbies.CustomerId = CustomerId; _HobbiesAndInterestsService.UpdateHobbiesAndInterests(hobbies); } else { HobbiesAndInterests objHobbies = new HobbiesAndInterests(); objHobbies.Music = Convert.ToInt32(Music); objHobbies.Hiking = Convert.ToInt32(Hiking); objHobbies.Camping = Convert.ToInt32(Camping); objHobbies.Photography = Convert.ToInt32(Photography); objHobbies.CustomerId = CustomerId; _HobbiesAndInterestsService.InsertHobbiesAndInterests(objHobbies); } Mapper.CreateMap <Customer, UserCustomerModel>(); UserCustomerModel userCustomerModel = Mapper.Map <Customer, UserCustomerModel>(Customer); userCustomerModel.Music = Music; userCustomerModel.Hiking = Hiking; userCustomerModel.Camping = Camping; userCustomerModel.Photography = Photography; return(ErrorMessage("success", userCustomerModel)); } catch (System.Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public void SendMailToAdmin(string UserName, string EmailAddress, string EmailVerifyCode, string subject, string Body, string TrebId, string FilledFormUrl) { try { string Logourl = CommonCls.GetURL() + "/images/EmailLogo.png"; string Imageurl = CommonCls.GetURL() + "/images/EmailPic.png"; // Send mail. MailMessage mail = new MailMessage(); string FromEmailID = WebConfigurationManager.AppSettings["FromEmailID"]; string FromEmailPassword = WebConfigurationManager.AppSettings["FromEmailPassword"]; string ToEmailID = WebConfigurationManager.AppSettings["ToEmailID"]; SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"]); int _Port = Convert.ToInt32(WebConfigurationManager.AppSettings["Port"].ToString()); Boolean _UseDefaultCredentials = Convert.ToBoolean(WebConfigurationManager.AppSettings["UseDefaultCredentials"].ToString()); Boolean _EnableSsl = Convert.ToBoolean(WebConfigurationManager.AppSettings["EnableSsl"].ToString()); mail.To.Add(new MailAddress(EmailAddress)); mail.From = new MailAddress(FromEmailID); mail.Subject = subject; //string LogoPath = Common.GetURL() + "/images/logo.png"; string msgbody = ""; msgbody += ""; msgbody += "<div>"; msgbody += "<div style='float:left;width:100%;'>"; msgbody += "<h2 style='float:left; width:100%; font-size:16px; font-family:arial; margin:0 0 10px;'>Dear Admin,</h2>"; // msgbody += "<div style='float:left;width:100%; margin:4px 0;'><p style='float:left; font-size:14px; font-family:arial; line-height:25px; margin:0 11px 0 0;'>This message refers to your post :</p> <span style='float:left; font-size:16px; font-family:arial; margin:2px 0 0 0;'>" + PropertyType + "</span>"; // msgbody += "</div>"; msgbody += "<p style='float:left;width:100%; font-size:14px; font-family:arial; line-height:25px; margin:0;'>" + Body + ""; msgbody += "</p>"; msgbody += "<p style='float:left;width:100%; font-size:14px; font-family:arial; line-height:25px; margin:0;'>User Name: <b>" + UserName + "</b>"; msgbody += "<p style='float:left;width:100%; font-size:14px; font-family:arial; line-height:25px; margin:0;'>Treb Id: <b>" + TrebId + "</b>"; msgbody += " <a style='color:red; width:100%;font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='" + FilledFormUrl + "'>Click here to Check filled from: </a>"; msgbody += "</p>"; //msgbody += "</p>"; //msgbody += "<p style='float:left;width:100%; font-size:14px; font-family:arial; line-height:25px; margin:0;'>Treb Id: <b>" + TrebId + "</b>"; msgbody += "</p>"; msgbody += "<span style='float:left; font-size:15px; font-family:arial; margin:12px 0 0 0; width:100%;'>Team</span>"; msgbody += "<div style='width:auto; float:left;'>"; msgbody += " <p style='font-family:arial; font-size:12px; font-weight:bold; margin:0px; padding:0px;'>Call: 416 844 5725 | 647 977 3268 </p>"; msgbody += " <p style='font-family:arial; font-size:12px; font-weight:bold; margin:0px; padding:0px;'>Fax: 647 497 5646 </p>"; msgbody += " <a style='color:red; width:100%; font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='www.http://www.only4agents.com'>Web:www.only4agents.com</a>"; msgbody += " <a style='color:red; width:100%;font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='*****@*****.**'>Email: [email protected]</a>"; msgbody += " <a style='color:red; width:100%;font-size:13px; float:left; margin:5px 0 0 0px; text-decoration:none; font-family:arial;' href='http://app.only4agents.com/'>Click here to login: www.app.only4agents.com/</a>"; msgbody += " </div>"; msgbody += "<div style='float:left; width:100%; margin:12px 0 6px 0;'>"; //msgbody +="<img style='float:left; width:150px;' src='data:image/png;base64,"+ LogoBase64 +"' /> <img style='float:left; width:310px; margin:30px 0 0 30px;' src='data:image/png;base64,"+ ImageBase64 +"' />"; msgbody += "<img style='float:left; width:500px;' src='" + Logourl + "' /> "; //<img style='float:left; width:310px; margin:30px 0 0 30px;' src='" + Imageurl + "' /> msgbody += "</div>"; msgbody += "</div>"; msgbody += "</div>"; mail.Body = msgbody; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Host = "smtp.gmail.com"; //_Host; smtp.Port = _Port; //smtp.UseDefaultCredentials = _UseDefaultCredentials; smtp.Credentials = new System.Net.NetworkCredential(FromEmailID, FromEmailPassword);// Enter senders User name and password smtp.EnableSsl = _EnableSsl; smtp.Send(mail); } catch (Exception ex) { string ErrorMsg = ex.ToString(); } }
public ActionResult ActiveProfile(int id) { var Customers = _CustomerService.GetCustomers().Where(c => c.CustomerId == id).FirstOrDefault(); var User = _UserService.GetUser(Customers.UserId); var models = new List <CustomerModel>(); CommonClass CommonClass = new CommonClass(); string QStr = ""; DataTable dt = new DataTable(); QStr = "Select * From Customer where CustomerId =" + id; dt = CommonClass.GetDataSet(QStr).Tables[0]; List <CustomerModel> CustomerList = new List <CustomerModel>(); CustomerModel CustomerEntity = new CustomerModel(); CustomerEntity.CustomerId = Convert.ToInt32(dt.Rows[0]["CustomerId"]); CustomerEntity.UserId = Convert.ToInt32(dt.Rows[0]["UserId"] as int?);; CustomerEntity.TrebId = (dt.Rows[0]["TrebId"]).ToString(); CustomerEntity.PhotoPath = (dt.Rows[0]["PhotoPath"]).ToString(); CustomerEntity.FirstName = (dt.Rows[0]["FirstName"]).ToString(); CustomerEntity.LastName = (dt.Rows[0]["LastName"]).ToString(); CustomerEntity.MiddleName = (dt.Rows[0]["MiddleName"]).ToString(); CustomerEntity.MobileNo = (dt.Rows[0]["MobileNo"]).ToString(); CustomerEntity.EmailID = (dt.Rows[0]["EmailId"]).ToString(); CustomerEntity.WebsiteUrl = (dt.Rows[0]["WebsiteUrl"]).ToString(); CustomerEntity.DOB = (dt.Rows[0]["DOB"]).ToString(); CustomerEntity.Designation = (dt.Rows[0]["Designation"]).ToString(); CustomerEntity.RecoNumber = (dt.Rows[0]["RecoNumber"]).ToString(); if (dt.Rows[0]["RecoExpireDate"] != DBNull.Value) { CustomerEntity.RecoExpireDate = Convert.ToDateTime((dt.Rows[0]["RecoExpireDate"])); } CustomerEntity.CreatedOn = Convert.ToDateTime(((dt.Rows[0]["CreatedOn"]).ToString() == "" ? "01/01/1900" : dt.Rows[0]["CreatedOn"])); if (dt.Rows[0]["LastUpdatedOn"] != DBNull.Value) { CustomerEntity.LastUpdatedOn = Convert.ToDateTime((dt.Rows[0]["LastUpdatedOn"])); } CustomerEntity.IsActive = Convert.ToBoolean((dt.Rows[0]["IsActive"])); if (dt.Rows[0]["UpdateStatus"] != DBNull.Value) { CustomerEntity.UpdateStatus = Convert.ToBoolean((dt.Rows[0]["UpdateStatus"])); } if (CustomerEntity.PhotoPath != null && CustomerEntity.PhotoPath != "") { CustomerEntity.PhotoPath = CustomerEntity.PhotoPath; } else { CustomerEntity.PhotoPath = CommonCls.GetURL() + "/images/noImage.jpg"; } if (User != null) { CustomerEntity.Password = User.Password; } ViewBag.CityID = (Customers.CityID <= 0 ? "" : Customers.CityID.ToString()); ViewBag.StateID = (Customers.StateID <= 0 ? "" : Customers.StateID.ToString()); ViewBag.Countrylist = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Customers.CountryID); ViewBag.Citylist = new SelectList(_CityService.GetCities(), "CityID", "CityName", Customers.CityID); ViewBag.UserId = new SelectList(_UserService.GetUsers(), "UserId", "FirstName", Customers.UserId); return(View(CustomerEntity)); }