public ActionResult Customers() { PDBC db = new PDBC(); var res = new List <CustomerModel>(); db.Connect(); DataTable dt = db.Select("SELECT [id_Customer],[C_Mobile],[C_regDate],[C_FirstName] +' '+[C_LastNAme] as C_Name,[C_Description],[C_ISActivate] FROM [tbl_Customer_Main]"); db.DC(); for (int i = 0; i < dt.Rows.Count; i++) { var model = new CustomerModel() { Num = i + 1, Id = Convert.ToInt32(dt.Rows[i]["id_Customer"]), Name = dt.Rows[i]["C_Name"].ToString(), Discription = dt.Rows[i]["C_Description"].ToString(), Phone = dt.Rows[i]["C_Mobile"].ToString(), IsActive = Convert.ToInt32(dt.Rows[i]["C_ISActivate"]), Reg_Date = DateConvert.DateReturner(dt.Rows[i]["C_regDate"].ToString(), "ShortDate") }; res.Add(model); } return(View(res)); }
public List <CustomerSidePostModel> Posttable() { var res = new List <CustomerSidePostModel>(); PDBC db = new PDBC(); db.Connect(); DataTable dt = db.Select("SELECT [Id],[Title],[GroupId],[Text_min],[Text],(SELECT [ad_firstname]+ ' '+ [ad_lastname] as name FROM [tbl_ADMIN_main]where id_Admin=[WrittenBy_AdminId])as adminName ,[Date],[IsImportant],[Is_Deleted],[Is_Disabled],(SELECT [name]FROM [tbl_BLOG_Categories] where Id=[Cat_Id]) as Category,(SELECT [name]FROM [tbl_BLOG_Groups] where G_Id=[GroupId]) as GroupName,(SELECT top 1 B.PicAddress FROM [tbl_BLOG_Pic_Connector] as A inner join [tbl_ADMIN_UploadStructure_ImageAddress] as B on A.[PicId]=B.PicID where A.PostId=Id)as Pic FROM [tbl_BLOG_Post] order by(date)desc"); db.DC(); for (int i = 0; i < dt.Rows.Count; i++) { var model = new CustomerSidePostModel() { Id = Convert.ToInt32(dt.Rows[i]["Id"]), by = dt.Rows[i]["adminName"].ToString(), Category = dt.Rows[i]["Category"].ToString(), InGroup = dt.Rows[i]["GroupName"].ToString(), ImagePath = dt.Rows[i]["Pic"].ToString(), IsDeleted = Convert.ToInt32(dt.Rows[i]["Is_Deleted"]), IsDisabled = Convert.ToInt32(dt.Rows[i]["Is_Disabled"]), text = dt.Rows[i]["Text"].ToString(), title = dt.Rows[i]["Title"].ToString(), text_min = dt.Rows[i]["Text_min"].ToString(), date = DateConvert.DateReturner(dt.Rows[i]["Date"].ToString(), "Date"), GPIDforPostPAge = dt.Rows[i]["GroupId"].ToString() }; res.Add(model); } return(res); }
public ActionResult customerProfileComments() { int CustomerId = 1009; string Query; Query = "SELECT [C_FirstName]+' '+[C_LastNAme] as name,[id_Customer],[CommentId],[Message],[date],[Title],[C_regDate],[id_MProduct],[VerifyType] FROM [v_CommentsList] WHERE id_Customer=@CustomerId ORDER BY([date])DESC"; var Comments = new List <CommentModel>(); PDBC db = new PDBC(); ExcParameters par = new ExcParameters() { _KEY = "@CustomerId", _VALUE = CustomerId }; List <ExcParameters> pars = new List <ExcParameters>(); pars.Add(par); db.Connect(); using (DataTable dt = db.Select(Query, pars)) { for (int i = 0; i < dt.Rows.Count; i++) { CommentModel Comment = new CommentModel() { ProId = Convert.ToInt32(dt.Rows[i]["id_MProduct"]), CusromerId = Convert.ToInt32(dt.Rows[i]["id_Customer"]), ProTitle = dt.Rows[i]["Title"].ToString(), CustomerName = dt.Rows[i]["name"].ToString(), ProductCode = "", C_RegisterDate = DateConvert.DateReturner(dt.Rows[i]["C_regDate"].ToString(), "ShortDate"), CommentDate = DateConvert.DateReturner(dt.Rows[i]["date"].ToString(), "ShortDate"), Message = dt.Rows[i]["Message"].ToString(), CommentId = Convert.ToInt32(dt.Rows[i]["CommentId"]), VerifyType = dt.Rows[i]["VerifyType"].ToString(), }; Comment.Reply = new List <ReplyModel>(); using (DataTable dtJ = db.Select("SELECT [AdminId],[ad_avatarprofile],[ad_firstname]+' '+[ad_lastname] as AdName,[CommentId],[Message],[RepId],[date] FROM [v_ReplyList] WHERE [CommentId]=" + Comment.CommentId + " order by([date])DESC")) { for (int j = 0; j < dtJ.Rows.Count; j++) { Comment.Reply.Add(new ReplyModel() { //= dtJ.Rows[j][""].ToString(), AdminId = Convert.ToInt32(dtJ.Rows[j]["AdminId"]), Message = dtJ.Rows[j]["Message"].ToString(), RepDate = DateConvert.DateReturner(dtJ.Rows[j]["date"].ToString(), "DateTime"), AdminName = dtJ.Rows[j]["AdName"].ToString(), AdminPic = dtJ.Rows[j]["ad_avatarprofile"].ToString(), RepId = Convert.ToInt32(dtJ.Rows[j]["RepId"]), }); } } } db.DC(); return(View(Comments)); } }
public ActionResult CustomerProfile(int id) { PDBC db = new PDBC(); var AddresList = new List <AddressModel>(); db.Connect(); DataTable dt1 = db.Select("SELECT DISTINCT B.[Ostan_name] , B.[Shahr_Name] as city ,[C_AddressHint],[C_FullAddress] FROM [tbl_Customer_Address] as A inner join [tbl_Enum_Shahr] as B on A.ID_Shahr=B.ID_Shahr where A.id_Customer=" + id); for (int i = 0; i < dt1.Rows.Count; i++) { var model = new AddressModel() { Num = i + 1, Ostan = dt1.Rows[i]["Ostan_name"].ToString(), City = dt1.Rows[i]["city"].ToString(), FullAddress = dt1.Rows[i]["C_FullAddress"].ToString(), HintAddress = dt1.Rows[i]["C_AddressHint"].ToString() }; AddresList.Add(model); } DataTable dt = db.Select("SELECT [id_Customer],[C_regDate],[C_Mobile],[C_FirstName],[C_LastNAme],[C_Description],[C_Email] FROM [tbl_Customer_Main]where id_Customer=" + id); db.DC(); var res = new Admin_CustomerDetail(); if (dt.Rows.Count != 0) { res.Id = Convert.ToInt32(dt.Rows[0]["id_Customer"]); res.Name = dt.Rows[0]["C_FirstName"].ToString(); res.Familly = dt.Rows[0]["C_LastNAme"].ToString(); res.Discription = dt.Rows[0]["C_Description"].ToString(); res.PhoneNum = dt.Rows[0]["C_Mobile"].ToString(); res.Email = dt.Rows[0]["C_Email"].ToString(); res.registerDate = DateConvert.DateReturner(dt.Rows[0]["C_regDate"].ToString(), "ShortDate"); res.Addresses = AddresList; } CustomerModelFiller modelFiller = new CustomerModelFiller(); CustomerProfileModelView Model = new CustomerProfileModelView() { CustomerModel = res, OstanHa = modelFiller.Ostanha() }; return(View(Model)); }
//public List<CustomerSidePostModel> PostModels_ByType(string Type_token, string DateType = "Date") //{ // var res = new List<CustomerSidePostModel>(); // PDBC db = new PDBC(); // db.Connect(); // DataTable dt1 = db.Select("SELECT [G_Id] FROM [tbl_BLOG_Groups] where [GpToken] LIKE N'" + Type_token + "'"); // if (dt1.Rows.Count != 0) // { // DataTable dt = db.Select("SELECT [Id],[Title],[Text_min],[Text],(SELECT [ad_firstname]+ ' '+ [ad_lastname] as name FROM [tbl_ADMIN_main]where id_Admin=[WrittenBy_AdminId])as adminName ,[Date],[IsImportant],[Is_Deleted],[Is_Disabled],(SELECT [name]FROM [tbl_BLOG_Categories] where Id=[Cat_Id]) as Category,(SELECT [name]FROM [tbl_BLOG_Groups] where G_Id=[GroupId]) as GroupName,(SELECT top 1 B.PicAddress FROM [tbl_BLOG_Pic_Connector] as A inner join [tbl_ADMIN_UploadStructure_ImageAddress] as B on A.[PicId]=B.PicID where A.PostId=Id)as Pic,(SELECT [ad_avatarprofile] FROM[tbl_ADMIN_main] where id_Admin=WrittenBy_AdminId) as AdminPic ,(SELECT[B_TypeToken] FROM [tbl_BLOG_PostType] WHERE B_TypeId=[TypeId]) as TypeId FROM [tbl_BLOG_Post] WHERE [GroupId] = " + dt1.Rows[0]["B_TypeId"]); // db.DC(); // for (int i = 0; i < dt.Rows.Count; i++) // { // var model = new CustomerSidePostModel() // { // Id = Convert.ToInt32(dt.Rows[i]["Id"]), // by = dt.Rows[i]["adminName"].ToString(), // Category = dt.Rows[i]["Category"].ToString(), // InGroup = dt.Rows[i]["GroupName"].ToString(), // GPIDforPostPAge = dt.Rows[i]["GroupId"].ToString(), // ImagePath = dt.Rows[i]["Pic"].ToString(), // IsDeleted = Convert.ToInt32(dt.Rows[i]["Is_Deleted"]), // IsDisabled = Convert.ToInt32(dt.Rows[i]["Is_Disabled"]), // text = dt.Rows[i]["Text"].ToString(), // title = dt.Rows[i]["Title"].ToString(), // text_min = dt.Rows[i]["Text_min"].ToString(), // date = DateConvert.DateReturner(dt.Rows[i]["Date"].ToString(), DateType), // AdminPic = dt.Rows[i]["AdminPic"].ToString(), // PostType = dt.Rows[i]["TypeId"].ToString() // }; // res.Add(model); // } // } // db.DC(); // return res; //} public List <CustomerSidePostModel> PostModels_Chosen(string Cat, int TopSelect, string DateType = "Date") { var res = new List <CustomerSidePostModel>(); PDBC db = new PDBC(); string Query = ""; if (Cat == "Popular") { Query = "SELECT top " + TopSelect + " [Id],[Title],[Text_min],[Text],(SELECT [ad_firstname]+ ' '+ [ad_lastname] as name FROM [tbl_ADMIN_main]where id_Admin=[WrittenBy_AdminId])as adminName ,[Date],[IsImportant],[Is_Deleted],[Is_Disabled],(SELECT [name]FROM [tbl_BLOG_Categories] where Id=[Cat_Id]) as Category,(SELECT [name]FROM [tbl_BLOG_Groups] where G_Id=[GroupId]) as GroupName,(SELECT top 1 B.PicAddress FROM [tbl_BLOG_Pic_Connector] as A inner join [tbl_ADMIN_UploadStructure_ImageAddress] as B on A.[PicId]=B.PicID where A.PostId=Id)as Pic,(SELECT [ad_avatarprofile] FROM[tbl_ADMIN_main] where id_Admin=WrittenBy_AdminId) as AdminPic ,(SELECT[B_TypeToken] FROM [tbl_BLOG_PostType] WHERE B_TypeId=[TypeId]) as TypeId FROM [tbl_BLOG_Post] Order By(SELECT COUNT(*) FROM [tbl_BLOG_Comment] WHERE PostId=Id) DESC,Date DESC"; } else if (Cat == "New") { Query = "SELECT top " + TopSelect + " [Id],[Title],[Text_min],[Text],(SELECT [ad_firstname]+ ' '+ [ad_lastname] as name FROM [tbl_ADMIN_main]where id_Admin=[WrittenBy_AdminId])as adminName ,[Date],[IsImportant],[Is_Deleted],[Is_Disabled],(SELECT [name]FROM [tbl_BLOG_Categories] where Id=[Cat_Id]) as Category,(SELECT [name]FROM [tbl_BLOG_Groups] where G_Id=[GroupId]) as GroupName,(SELECT top 1 B.PicAddress FROM [tbl_BLOG_Pic_Connector] as A inner join [tbl_ADMIN_UploadStructure_ImageAddress] as B on A.[PicId]=B.PicID where A.PostId=Id)as Pic,(SELECT [ad_avatarprofile] FROM[tbl_ADMIN_main] where id_Admin=WrittenBy_AdminId) as AdminPic ,(SELECT[B_TypeToken] FROM [tbl_BLOG_PostType] WHERE B_TypeId=[TypeId]) as TypeId FROM [tbl_BLOG_Post] Order By(Date)DESC"; } db.Connect(); DataTable dt = db.Select(Query); db.DC(); for (int i = 0; i < dt.Rows.Count; i++) { var model = new CustomerSidePostModel() { Id = Convert.ToInt32(dt.Rows[i]["Id"]), by = dt.Rows[i]["adminName"].ToString(), Category = dt.Rows[i]["Category"].ToString(), InGroup = dt.Rows[i]["GroupName"].ToString(), GPIDforPostPAge = dt.Rows[i]["GroupId"].ToString(), ImagePath = dt.Rows[i]["Pic"].ToString(), IsDeleted = Convert.ToInt32(dt.Rows[i]["Is_Deleted"]), IsDisabled = Convert.ToInt32(dt.Rows[i]["Is_Disabled"]), text = dt.Rows[i]["Text"].ToString(), title = dt.Rows[i]["Title"].ToString(), text_min = dt.Rows[i]["Text_min"].ToString(), date = DateConvert.DateReturner(dt.Rows[i]["Date"].ToString(), DateType), AdminPic = dt.Rows[i]["AdminPic"].ToString(), PostType = dt.Rows[i]["TypeId"].ToString() }; res.Add(model); } return(res); }
public List <CustomerSidePostModel> UserPostModels(string Cat, int Page, int Id, string search, string DateType = "Date") { var res = new List <CustomerSidePostModel>(); PDBC db = new PDBC(); db.Connect(); DataTable dt = db.Select(QueryMaker_BlogPost(Cat, Page, Id, search)); db.DC(); for (int i = 0; i < dt.Rows.Count; i++) { var model = new CustomerSidePostModel() { Id = Convert.ToInt32(dt.Rows[i]["Id"]), by = dt.Rows[i]["adminName"].ToString(), Category = dt.Rows[i]["Category"].ToString(), InGroup = dt.Rows[i]["GroupName"].ToString(), GPIDforPostPAge = dt.Rows[i]["GroupId"].ToString(), ImagePath = dt.Rows[i]["Pic"].ToString(), IsDeleted = Convert.ToInt32(dt.Rows[i]["Is_Deleted"]), IsDisabled = Convert.ToInt32(dt.Rows[i]["Is_Disabled"]), text = dt.Rows[i]["Text"].ToString(), title = dt.Rows[i]["Title"].ToString(), text_min = dt.Rows[i]["Text_min"].ToString(), date = DateConvert.DateReturner(dt.Rows[i]["Date"].ToString(), DateType), AdminPic = dt.Rows[i]["AdminPic"].ToString() }; if (string.IsNullOrEmpty(model.ImagePath)) { model.ImagePath = NoImage; } res.Add(model); } return(res); }
public SinglePostPostDetail SinglePostFiller(int idPost, string DateType = "Date") { SinglePostPostDetail result = new SinglePostPostDetail(); PDBC db = new PDBC(); db.Connect(); using (DataTable dt = db.Select("SELECT * FROM [v_Blog_SinglePost] WHERE PostID = " + idPost)) { if (dt.Rows.Count > 0) { result.Cat_Id = dt.Rows[0]["Cat_Id"].ToString(); result.GroupId = dt.Rows[0]["GroupId"].ToString(); result.Gpname = dt.Rows[0]["Gpname"].ToString(); result.CatName = dt.Rows[0]["CatName"].ToString(); result.Title = dt.Rows[0]["Title"].ToString(); result.Text_min = dt.Rows[0]["Text_min"].ToString(); result.Text = dt.Rows[0]["Text"].ToString(); result.Date = DateConvert.DateReturner(dt.Rows[0]["Date"].ToString(), DateType); result.weight = dt.Rows[0]["weight"].ToString(); result.IsImportant = dt.Rows[0]["IsImportant"].ToString(); result.PostID = dt.Rows[0]["PostID"].ToString(); result.WrittenBy_AdminId = dt.Rows[0]["WrittenBy_AdminId"].ToString(); result.ad_firstname = dt.Rows[0]["ad_firstname"].ToString(); result.ad_lastname = dt.Rows[0]["ad_lastname"].ToString(); result.ad_avatarprofile = dt.Rows[0]["ad_avatarprofile"].ToString(); DataTable Comments = db.Select("SELECT [Id],[Email],[message],[Date] FROM [tbl_BLOG_Comment] where PostId=" + idPost); var Com = new List <CommentsModel>(); db.DC(); db.Connect(); for (int i = 0; i < Comments.Rows.Count; i++) { var Rep = new List <CommentsModel>(); DataTable rep = db.Select("SELECT [Id],[Email],[Message],[Date]FROM [tbl_BLOG_Reply] where commentId=" + Comments.Rows[i]["Id"]); for (int j = 0; j < rep.Rows.Count; j++) { var Rmodel = new CommentsModel() { Id = Convert.ToInt32(rep.Rows[j]["Id"]), Email = rep.Rows[j]["Email"].ToString(), Message = rep.Rows[j]["Message"].ToString(), Date = DateConvert.DateReturner(rep.Rows[j]["Date"].ToString(), DateType) }; Rep.Add(Rmodel); } var model = new CommentsModel() { Id = Convert.ToInt32(Comments.Rows[i]["Id"]), Email = Comments.Rows[i]["Email"].ToString(), Message = Comments.Rows[i]["Message"].ToString(), Date = DateConvert.DateReturner(Comments.Rows[i]["Date"].ToString(), DateType), Reply = Rep }; Com.Add(model); } result.Comments = Com; } else { result.PostID = "0"; } } db.DC(); return(result); }