public void SaveLog() { if (C_LikeViewList.CompareListCreateTimeWithTimeNow()) { var LstLikeView = C_LikeViewList.GetAllLikeView(); if (LstLikeView.Count() != 0) { using (var _Context = new ApplicationDbContext()) { var _objEntityActivity = new RepositoryPattern <Activity>(_Context); foreach (var item in LstLikeView) { if (item.ActionTypeID == Convert.ToInt32(EnumMethod.ActionType.View) || item.ActionTypeID == Convert.ToInt32(EnumMethod.ActionType.Like) || item.ActionTypeID == Convert.ToInt32(EnumMethod.ActionType.Downlaod)) { var NewItem = new Activity { ActionTime = item.ActionTime, DateMiladi = item.DateMiladi, DateShamsi = item.DateShamsi, ActivityTypeId = item.ActionTypeID, PostId = item.PostID, Browser = item.Browser, Device = item.Device, IP_Address = item.IP_Address, HostName = item.HostName, MoreInfo = "" }; _objEntityActivity.Insert(NewItem); } else if (item.ActionTypeID == Convert.ToInt32(EnumMethod.ActionType.DisLike)) { var CurrItemDele = _objEntityActivity.GetByPredicate(x => x.PostId == item.PostID && x.Browser == item.Browser && x.Device == item.Device && x.HostName == item.HostName && x.IP_Address == item.IP_Address && x.ActivityTypeId == Convert.ToInt32(EnumMethod.ActionType.Like)); if (CurrItemDele != null) { _objEntityActivity.Delete(CurrItemDele.ID); } } } _objEntityActivity.Save(); _objEntityActivity.Dispose(); C_LikeViewList.ClearLikeViewList(); } } } }
public async Task <ActionResult> Contact_US(string Name, string Phone, string Email, string Message, string CaptchaText) { if (CaptchaText.ToLower() == HttpContext.Session["captchastring"].ToString().ToLower()) { Session.Remove("captchastring"); var _objEntityMessage = new RepositoryPattern <Comment>(new ApplicationDbContext()); var NewItem = new Comment { FullName = Name, PhoneNumber = Phone, Email = Email, CommentUser = Message, SendDate = DateConvertor.DateToNumber(DateConvertor.TodayDate()), SendTime = DateConvertor.TimeNow(), Is_Read = "0" }; _objEntityMessage.Insert(NewItem); _objEntityMessage.Save(); _objEntityMessage.Dispose(); try { OpratingClasses.EmailService emailService = new OpratingClasses.EmailService(); var strSubject = " نام و نام خانوادگی : " + NewItem.FullName; var strMessage = " ارتباط با مديريت وب سايت" + " <br /> " + NewItem.CommentUser + " <br /> " + " ایمیل : " + NewItem.Email + " <br /> " + " شماره همراه : " + NewItem.PhoneNumber + " <br /> " + " تاریخ و ساعت ارسال : " + NewItem.SendDate + " - " + NewItem.SendTime; await emailService.SendMail(strSubject, strMessage); } catch (Exception) { } return(Json("OK")); } else { return(Json("CaptchaTextMistake")); //ViewBag.Message = "CAPTCHA verification failed!"; } }
public string CreateDataBaseConnection(DataBaseConnectionServiceModel dataBaseConnection) { try { if (dataBaseConnection == null) { } using (var dataBaseRepo = new RepositoryPattern <DatabaseConnection>()) { var data = Mapper.Map <DatabaseConnection>(dataBaseConnection); dataBaseRepo.Insert(data); dataBaseRepo.Save(); } return(""); } catch (Exception ex) { return(null); } }
//public ContentResult UploadFile(HttpPostedFileBase hpf,List<vm_FileUploadInfo> vm_Info) public JsonResult PublishPost(vmPublishPost input) //string Title, int CategoryID, string Content, string IsActive, bool FlagHaveFile,string Tagsinput) { //, string Labels try { string NewImageID; //InfoUser AppUser = new InfoUser(); var TodayDateShamsi = DateConvertor.DateToNumber(DateConvertor.TodayDate()); //var NewNewsCode = HelpOperation.NewsCode(Convert.ToInt32(TodayDateShamsi)); if (input.FlagHaveFile == true) { HelpOperation.CreateArchiveFolderOnTheServer(); HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; var FileSize = HelpOperation.ToFileSize(hpf.ContentLength); var GuidID = HelpOperation.NewGuidID(); var FileNameOnServer = GuidID + Path.GetExtension(hpf.FileName); var FilePath = @"~\MediaFiles\Image\" + FileNameOnServer; var FilePathOnServer = Server.MapPath(FilePath); var FileUrl = HelpOperation.MapToUrl(FilePath); Request.Files[0].SaveAs(FilePathOnServer); using (var _ContextImage = new ApplicationDbContext()) { var _objEntityImage = new RepositoryPattern <Image>(_ContextImage); var NewItemImage = new Image { ID = GuidID, TitleUrl = input.Title, FileName = FileNameOnServer, FileSize = FileSize, FileUrl = FileUrl, FilePathOnServer = FilePath }; NewImageID = GuidID; _objEntityImage.Insert(NewItemImage); _objEntityImage.Save(); _objEntityImage.Dispose(); } using (var _ContextPost = new ApplicationDbContext()) { var objEntityPost = new RepositoryPattern <Post>(_ContextPost); var newItemPost = new Post { Title = input.Title.Trim(), ImageID = NewImageID, CategoryID = input.CategoryID, //Categories = new List<Category>() { new Category() {ID = CategoryID, } }, Content = input.Content, IsActive = input.IsActive == "true" ? "0" : "1", Labels = input.Tagsinput.Trim(), SeoMetaDescription = input.SeoMetaDescription.Trim(), PostDate = DateConvertor.DateToNumber(DateConvertor.TodayDate()), PostTime = DateConvertor.TimeNowShort() }; objEntityPost.Insert(newItemPost); objEntityPost.Save(); objEntityPost.Dispose(); } } return(Json("OK")); } catch (Exception) { return(Json("Faild")); } }
public JsonResult EditPost(vmPublishPost input) { try { //delete image of Post To Insert New Image For Post (Update) if (input.FlagHaveFile == true) { DatabaseOperation objDatabaseOperation = new DatabaseOperation(); using (var _Context1 = new ApplicationDbContext()) { var objEntityPost = new RepositoryPattern <Post>(_Context1); var CurrentItem = objEntityPost.GetByPredicate(x => x.ID == input.PostID); if (objDatabaseOperation.DeleteImageOfPost(CurrentItem.ImageID)) { //InfoUser AppUser = new InfoUser(); var TodayDateShamsi = DateConvertor.DateToNumber(DateConvertor.TodayDate()); //var NewNewsCode = HelpOperation.NewsCode(Convert.ToInt32(TodayDateShamsi)); HelpOperation.CreateArchiveFolderOnTheServer(); HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; var FileSize = HelpOperation.ToFileSize(hpf.ContentLength); var GuidID = CurrentItem.ImageID; var FileNameOnServer = GuidID + Path.GetExtension(hpf.FileName); var FilePath = @"~\MediaFiles\Image\" + FileNameOnServer; var FilePathOnServer = Server.MapPath(FilePath); var FileUrl = HelpOperation.MapToUrl(FilePath); Request.Files[0].SaveAs(FilePathOnServer); using (var _ContextImage = new ApplicationDbContext()) { var _objEntityImage = new RepositoryPattern <Image>(_ContextImage); var NewItemImage = new Image { ID = GuidID, TitleUrl = input.Title, FileName = FileNameOnServer, FileSize = FileSize, FileUrl = FileUrl, FilePathOnServer = FilePath }; _objEntityImage.Insert(NewItemImage); _objEntityImage.Save(); _objEntityImage.Dispose(); } } } } using (var _context = new ApplicationDbContext()) { var objEntityPost = new RepositoryPattern <Post>(_context); var CurrentItem = objEntityPost.GetByPredicate(x => x.ID == input.PostID); CurrentItem.Title = input.Title.Trim(); CurrentItem.CategoryID = input.CategoryID; //Categories = new List<Category>() { new Category() {ID = CategoryID, } }, CurrentItem.Content = input.Content; CurrentItem.IsActive = input.IsActive == "true" ? "0" : "1"; CurrentItem.Labels = input.Tagsinput.Trim(); CurrentItem.SeoMetaDescription = input.SeoMetaDescription.Trim(); //CurrentItem.PostDate = DateConvertor.DateToNumber(DateConvertor.TodayDate()); //CurrentItem.PostTime = DateConvertor.TimeNowShort(); objEntityPost.Update(CurrentItem); objEntityPost.Save(); objEntityPost.Dispose(); } return(Json("OK")); } catch (Exception) { return(Json("Faild")); } }
public void AddCustomer(Customers customer) { repo.Insert(customer); }
public void AddEmployee(Employees employee) { repo.Insert(employee); }
public string SaveTableConfiguraionDetails(TableAndFieldConfigurationServiceModel tableAndFieldConfiguration) { try { if (tableAndFieldConfiguration == null) { //return exce } if (!tableAndFieldConfiguration.fieldConfiguration.Any()) { //return } var tableConfigData = Mapper.Map <TableConfiguration>(tableAndFieldConfiguration.tableConfiguration); using (var tableConfigRepo = new RepositoryPattern <TableConfiguration>()) { tableConfigRepo.Insert(tableConfigData); tableConfigRepo.Save(); } //for entry in table tableAndFieldConfiguration.fieldConfiguration.ForEach(v => { v.TableConfigId = tableConfigData.Id; v.IsDisplay = true; }); List <FieldConfiguration> fieldDetails = Mapper.Map <List <FieldConfiguration> >(tableAndFieldConfiguration.fieldConfiguration); using (var fieldConfigRepo = new RepositoryPattern <FieldConfiguration>()) { fieldConfigRepo.BulkInsert(fieldDetails); } List <FieldMappingConfiguration> fieldMappingConfigurations = new List <FieldMappingConfiguration>(); tableAndFieldConfiguration.fieldConfiguration.ForEach(field => { var dataWithId = fieldDetails.FirstOrDefault(a => a.SourceColumnName == field.SourceColumnName && a.TableConfigId == field.TableConfigId && a.ReferenceTableName == field.ReferenceTableName && a.ReferenceColumnName == field.ReferenceColumnName).Id; field.Id = dataWithId; }); tableAndFieldConfiguration.fieldConfiguration.ForEach(field => { if (!string.IsNullOrWhiteSpace(field.ReferenceTableName) && !string.IsNullOrWhiteSpace(field.ReferenceColumnName)) { if (field.MappedCoumns.Any()) { field.MappedCoumns.ForEach(m => { var mappingDetails = new FieldMappingConfiguration() { FieldConfigurationId = field.Id, MapColumnName = m, MapTableName = field.ReferenceTableName, }; fieldMappingConfigurations.Add(mappingDetails); }); } } }); if (fieldMappingConfigurations.Any()) { using (var fieldMappingConfigRepo = new RepositoryPattern <FieldMappingConfiguration>()) { fieldMappingConfigRepo.BulkInsert(fieldMappingConfigurations); } } return("Table Configuration Saved Succefully"); } catch (Exception ex) { throw; } }
public void StartOperation(string CurrentClientIP) { NetworkOperation objNetworkOperation = new NetworkOperation(); //string CurrentClientIP = ClientIPaddress(); IpInformation IpInfo = GetLocationIPINFO(CurrentClientIP); var _objEntityWebsiteVisit = new RepositoryPattern <WebsiteVisit>(new ApplicationDbContext()); var newItem = new WebsiteVisit { VisitTime = TimeNow(), DateShamsi = DateConvertor.DateToNumber(DateConvertor.TodayDate()), DateMiladi = DateConvertor.DateToNumber(DateConvertor.TodayDateMiladi()), Browser = objNetworkOperation.ClientBrowser(), DeviceInfo = objNetworkOperation.ClientDeviceType(), IP_Address = CurrentClientIP, HostName = objNetworkOperation.ClientHostName(), country = IpInfo.country, //asn = IpInfo.@as, city = IpInfo.city, countryCode = IpInfo.countryCode, isp = IpInfo.isp, lat = IpInfo.lat, lon = (IpInfo.lon), org = IpInfo.org, query = IpInfo.query, region = IpInfo.region, regionName = IpInfo.regionName, status = IpInfo.status, timezone = IpInfo.timezone, zip = IpInfo.zip, district = IpInfo.district, mobile = IpInfo.mobile, // == true? "1" : "0", proxy = IpInfo.proxy, // == true ? "1" : "0" reverse = IpInfo.reverse }; _objEntityWebsiteVisit.Insert(newItem); _objEntityWebsiteVisit.Save(); try { var strSubject = " بازديد از وبسايت " + newItem.DateShamsi + " " + newItem.VisitTime; var strMessage = " بازديد وب سايت" + " <br /> " + " IP Address : " + newItem.IP_Address + " <br /> " + " مشخصات دستگاه : " + newItem.DeviceInfo + " <br /> " + " كشور : " + newItem.country + " <br /> " + " شهر و منطقه : " + newItem.regionName + " - " + newItem.city; OpratingClasses.EmailService emailService = new OpratingClasses.EmailService(); Task.Factory.StartNew(() => emailService.SendMail(strSubject, strMessage)); } catch (Exception) { } var cou = newItem.ID; _objEntityWebsiteVisit.Dispose(); }
public async Task <ActionResult> AddComment(vmComment input) { if (!ModelState.IsValid) { foreach (var item in ModelState) { var errors = item.Value.Errors.ToList(); } return(Json("null")); } if (input.CaptchaText.ToLower() == HttpContext.Session["captchastring"].ToString().ToLower()) { Session.Remove("captchastring"); NetworkOperation objNetworkOperation = new NetworkOperation(); VisitWebsiteLog visitWebsiteLog = new VisitWebsiteLog(); string CurrentClientIP = null; CurrentClientIP = objNetworkOperation.ClientIPaddress(); IpInformation IpInfo = visitWebsiteLog.GetLocationIPINFO(CurrentClientIP); var _objEntityMessage = new RepositoryPattern <PostComment>(new ApplicationDbContext()); var NewItem = new PostComment { PostID = input.PostID, FullName = input.FullName, Comment = input.Comment, Email = input.Email, SendDate = DateConvertor.DateToNumber(DateConvertor.TodayDate()), SendTime = DateConvertor.TimeNow(), Browser = objNetworkOperation.ClientBrowser(), DeviceInfo = objNetworkOperation.ClientDeviceType(), IP_Address = CurrentClientIP, HostName = objNetworkOperation.ClientHostName(), country = IpInfo.country, city = IpInfo.city, countryCode = IpInfo.countryCode, org = IpInfo.org, region = IpInfo.region, regionName = IpInfo.regionName, status = IpInfo.status, timezone = IpInfo.timezone, mobile = IpInfo.mobile == true ? true :false, Is_Active = "1" }; _objEntityMessage.Insert(NewItem); _objEntityMessage.Save(); _objEntityMessage.Dispose(); try { var _objEntityPost = new RepositoryPattern <Post>(new ApplicationDbContext()); OpratingClasses.EmailService emailService = new OpratingClasses.EmailService(); var strSubject = " نام و نام خانوادگی : " + NewItem.FullName; var strMessage = " ديدگاه كاربر راجع به پست : " + _objEntityPost.GetByPredicate(X => X.ID == NewItem.PostID).Title.Trim() + " <br /> " + NewItem.Comment + " <br /> " + " ایمیل : " + NewItem.Email + " <br /> " + " ساير اطلاعات : " + NewItem.DeviceInfo + " - " + NewItem.country + NewItem.city + " <br /> " + " تاریخ و ساعت ارسال : " + NewItem.SendDate + " - " + NewItem.SendTime; //" <br /> <p styel=\"font-family:\"Tahoma;\"\">" + NewItem.Comment + await emailService.SendMail(strSubject, strMessage); } catch (Exception) { } return(PartialView("_PartialPageComment", NewItem)); } else { return(Json("CaptchaTextMistake")); //ViewBag.Message = "CAPTCHA verification failed!"; } }