/// <summary> /// Validate User login details /// </summary> /// <param name="UserName"></param> /// <param name="Password"></param> /// <returns></returns> public UserInfoEntity ValidateUser(string UserName, string Password) { UserInfoEntity _userInfo = new UserInfoEntity(); try { using (var dao = DbActivity.Open()) { CSqlDbCommand cmd = new CSqlDbCommand(DataHelper.DBCommands.VALIDATE_USERINFO); cmd.Parameters.AddWithValue("UserName", UserName); cmd.Parameters.AddWithValue("Password", Password); dao.ExecReader(cmd); while (dao.DataReader.Read()) { _userInfo = new UserInfoEntity(); _userInfo.UserId = dao.DataReader["UserId"].ToInt(); _userInfo.UserName = dao.DataReader["UserName"].ToStr(); _userInfo.Password = dao.DataReader["Password"].ToStr(); _userInfo.Role = dao.DataReader["Role"].ToStr(); _userInfo.UpdatedOn = dao.DataReader["UpdatedOn"].ToDateTime(); _userInfo.ExpiredDate = dao.DataReader["ExpiredDate"].ToDateTime(); } } } catch (Exception ex) { LoggerMgr.Web.Error(LoggerMgr.GetErrorMessageRootText(DataHelper.Layer.DataAccessLayer, DataHelper.DataAccess.OrdersContext, MethodInfo.GetCurrentMethod().Name), ex); throw; } return(_userInfo); }
/// <summary> /// Get Product list based on order id /// </summary> /// <param name="_orderId"></param> /// <returns></returns> public List <ProductEntity> GetProductDetails(int _orderId) { List <ProductEntity> _productEntity = new List <ProductEntity>(); try { using (var dao = DbActivity.Open()) { CSqlDbCommand cmd = new CSqlDbCommand(DataHelper.DBCommands.USP_GET_PRODUCTLIST); cmd.Parameters.AddWithValue("OrderId", _orderId); dao.ExecReader(cmd); while (dao.DataReader.Read()) { _productEntity.Add(new ProductEntity() { OrderId = dao.DataReader["OrderId"].ToInt(), SKUID = dao.DataReader["SKUID"].ToInt(), Name = dao.DataReader["Name"].ToStr(), Weight = dao.DataReader["Weight"].ToDecimal(), Height = dao.DataReader["Height"].ToDecimal(), Quantity = dao.DataReader["Quantity"].ToInt(), Amount = dao.DataReader["Amount"].ToDecimal(), Image = dao.DataReader["Image"].ToStr(), Barcode = dao.DataReader["Barcode"] == DBNull.Value ? new byte() :Convert.ToByte(dao.DataReader["Barcode"]), }); } } } catch (Exception ex) { LoggerMgr.Web.Error(LoggerMgr.GetErrorMessageRootText(DataHelper.Layer.DataAccessLayer, DataHelper.DataAccess.OrdersContext, MethodInfo.GetCurrentMethod().Name), ex); throw; } return(_productEntity); }
/// <summary> /// Save order information /// </summary> /// <param name="_ordersInfo"></param> public int SaveOrderlist(OrdersEntity _ordersInfo) { int ResultsId = 0; using (var dao = DbActivity.Open()) { try { dao.BeginTrans(); CSqlDbCommand cmd = new CSqlDbCommand(DataHelper.DBCommands.USP_SAVE_ORDERINFO); cmd.Parameters.AddWithValue("OrderId", _ordersInfo.OrderId); cmd.Parameters.AddWithValue("BuyerId", _ordersInfo.BuyerId); cmd.Parameters.AddWithValue("OrderStatus", _ordersInfo.OrderStatus); cmd.Parameters.AddWithValue("LastName", _ordersInfo.BuyerInfoDetail.LastName); cmd.Parameters.AddWithValue("FirstName", _ordersInfo.BuyerInfoDetail.FirstName); cmd.Parameters.AddWithValue("Mobile", _ordersInfo.BuyerInfoDetail.PhoneNumber); cmd.Parameters.AddWithValue("Email", _ordersInfo.BuyerInfoDetail.Email); cmd.Parameters.AddWithValue("Address", _ordersInfo.BuyerInfoDetail.Address); cmd.Parameters.Add("BuyerResultId", _ordersInfo.BuyerInfoDetail.BuyerId, ParameterDirection.InputOutput, DbType.Int32); dao.ExecCommand(cmd); ResultsId = dao.Parameters["BuyerResultId"].Value.ToInt(); SaveProductsInfo(_ordersInfo.ProductInfoDetail, ResultsId, dao); dao.Commit(); } catch (Exception ex) { dao.Rollback(); LoggerMgr.Web.Error(LoggerMgr.GetErrorMessageRootText(DataHelper.Layer.DataAccessLayer, DataHelper.DataAccess.OrdersContext, MethodInfo.GetCurrentMethod().Name), ex); throw; } } return(ResultsId); }
/// <summary> /// Get Orderlist /// </summary> /// <returns></returns> public List <OrdersEntity> GetAllOrders(int?_orderId) { List <OrdersEntity> _ordersEntity = new List <OrdersEntity>(); try { using (var dao = DbActivity.Open()) { CSqlDbCommand cmd = new CSqlDbCommand(DataHelper.DBCommands.USP_GET_ORDERLIST); cmd.Parameters.AddWithValue("OrderId", _orderId); dao.ExecReader(cmd); while (dao.DataReader.Read()) { _ordersEntity.Add(new OrdersEntity() { OrderId = dao.DataReader["OrderId"].ToInt(), BuyerId = dao.DataReader["BuyerId"].ToInt(), OrderStatus = dao.DataReader["Status_Code"].ToStr(), BuyerInfoDetail = new BuyerEntity() { BuyerId = dao.DataReader["BuyerId"].ToInt(), LastName = dao.DataReader["LastName"].ToStr(), FirstName = dao.DataReader["FirstName"].ToStr(), PhoneNumber = dao.DataReader["Mobile"].ToStr(), Email = dao.DataReader["Email"].ToStr(), Address = dao.DataReader["Address"].ToStr() }, ProductInfoDetail = GetProductDetails(dao.DataReader["OrderId"].ToInt()) }); } } } catch (Exception ex) { LoggerMgr.Web.Error(LoggerMgr.GetErrorMessageRootText(DataHelper.Layer.DataAccessLayer, DataHelper.DataAccess.OrdersContext, MethodInfo.GetCurrentMethod().Name), ex); throw; } return(_ordersEntity); }
/// <summary> /// Delete Order id /// </summary> /// <param name="_orderId"></param> /// <returns></returns> public int DeleteOrderId(int _orderId) { int result = 0; using (var dao = DbActivity.Open()) { try { CSqlDbCommand cmd = new CSqlDbCommand(DataHelper.DBCommands.USP_DELETE_ORDER); cmd.Parameters.AddWithValue("OrderId", _orderId); result = dao.ExecCommand(cmd); dao.Commit(); } catch (Exception ex) { dao.Rollback(); LoggerMgr.Web.Error(LoggerMgr.GetErrorMessageRootText(DataHelper.Layer.DataAccessLayer, DataHelper.DataAccess.OrdersContext, MethodInfo.GetCurrentMethod().Name), ex); throw; } return(result); } }