private void ProvideComments() { UserCommentsEntity uce = new UserCommentsEntity(); try { var lst = abal.GetProducts(); Console.WriteLine("{0,10}{1,20}{2,20}{3,20}", "ID", "Product Name", "Price", "Discount"); foreach (var l in lst) { Console.WriteLine("{0,10}{1,20}{2,20}{3,20}", l.ProdId, l.ProductName, l.Price, l.Discount); } Console.WriteLine("Enter Product ID"); uce.ProdID = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Comment on Product"); uce.CommentDescription = Console.ReadLine(); var res = ubal.AddCommentByProduct(uce); if (res) { Console.WriteLine("User Comment on Product is Added Successfully"); } Console.WriteLine("Do You Want to Continue(Y/N)?"); char ans = char.Parse(Console.ReadLine()); if ((ans == 'Y') || (ans == 'y')) { MenuUser(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal UserCommentsEntity GetUserCommentsById(int commentId) { UserCommentsEntity results = new UserCommentsEntity(); try { StoredProcedureEntity sproc = new StoredProcedureEntity(); sproc.StoredProcedureName = "dnb.GetUserCommentsById"; sproc.StoredProceduresParameter.Add(GetParam("@CommentId", commentId.ToString(), SQLServerDatatype.IntDataType)); DataTable dt; dt = sql.ExecuteDataTable(CommandType.StoredProcedure, sproc, ""); if (dt != null && dt.Rows.Count > 0) { UserCommentsAdapter ta = new UserCommentsAdapter(); foreach (DataRow rw in dt.Rows) { results = ta.AdaptItem(rw); } } } catch (Exception) { throw; } return(results); }
internal void InsertUserComments(UserCommentsEntity obj) { try { StoredProcedureEntity sproc = new StoredProcedureEntity(); sproc.StoredProcedureName = "dnb.InsertUserComments"; sproc.StoredProceduresParameter.Add(GetParam("@CommentType", obj.CommentType.ToString(), SQLServerDatatype.VarcharDataType)); sproc.StoredProceduresParameter.Add(GetParam("@Comment", obj.Comment.ToString(), SQLServerDatatype.VarcharDataType)); sql.ExecuteNoReturn(CommandType.StoredProcedure, sproc); } catch (Exception ex) { throw ex; } }
public ActionResult AddUserComments(List <UserCommentsEntity> UserComments) { //if (Session["Username"] == null) //{ // return RedirectToAction("PageNotfound"); //} UserCommentsEntity ucent = new UserCommentsEntity(); Session["Order"] = ucent.Order_No; //ucent.User_name = Session["Username"].ToString(); //ucent AddSerialBL obj = new AddSerialBL(); return(Json(obj.AddUserComments(UserComments), JsonRequestBehavior.AllowGet)); }
public bool AddCommentByProduct(UserCommentsEntity uc) { bool result = false; try { if (con.State != ConnectionState.Open) { con.Open(); } com = con.CreateCommand(); string query = "insert into UserCommentTable values(@cdate,@uid,@pid,@cdesc)"; com.CommandText = query; IDataParameter cdate = com.CreateParameter(); cdate.ParameterName = "@cdate"; cdate.Value = DateTime.Now; com.Parameters.Add(cdate); IDataParameter uid = com.CreateParameter(); uid.ParameterName = "@uid"; uid.Value = LoginDAL.UID; com.Parameters.Add(uid); IDataParameter pid = com.CreateParameter(); pid.ParameterName = "@pid"; pid.Value = uc.ProdID; com.Parameters.Add(pid); IDataParameter cdesc = com.CreateParameter(); cdesc.ParameterName = "@cdesc"; cdesc.Value = uc.CommentDescription; com.Parameters.Add(cdesc); var res = com.ExecuteNonQuery(); if (res > 0) { result = true; } } catch (Exception ex) { throw ex; } finally { con.Close(); } return(result); }
public bool AddCommentByProduct(UserCommentsEntity uc) { try { if (uc.ProdID <= 0) { throw new Exception("Product ID cannot be zero or negative"); } if (string.IsNullOrEmpty(uc.CommentDescription) || string.IsNullOrWhiteSpace(uc.CommentDescription)) { throw new Exception("Comment Description cannot be blank"); } return(dal.AddCommentByProduct(uc)); } catch (ApplicationException ex) { throw ex; } }
public List <UserCommentsEntity> ViewComments(string username) { List <UserCommentsEntity> uc = new List <UserCommentsEntity>(); try { int usrid = GetUserID(username); if (con.State != ConnectionState.Open) { con.Open(); } com = con.CreateCommand(); string query = "select * from UserCommentTable where UserID=@uid"; com.CommandText = query; IDataParameter uid = com.CreateParameter(); uid.ParameterName = "@uid"; uid.Value = usrid; com.Parameters.Add(uid); r = com.ExecuteReader(); while (r.Read()) { UserCommentsEntity ue = new UserCommentsEntity(); ue.CommentID = Convert.ToInt32(r[0]); ue.CommentDate = Convert.ToDateTime(r[1]); ue.UserID = Convert.ToInt32(r[2]); ue.ProdID = Convert.ToInt32(r[3]); ue.CommentDescription = r[4].ToString(); uc.Add(ue); } } catch (Exception ex) { throw ex; } finally { con.Close(); } return(uc); }
public void UpdateUserComments(UserCommentsEntity objTags) { rep.UpdateUserComments(objTags); }
public void InsertUserComments(UserCommentsEntity objTags) { rep.InsertUserComments(objTags); }