public async Task <ApiResult <bool> > AddToServiceCartAsync(AddServiceCartRequestViewModel model, int userId)
        {
            bool iSFromDiffrentService = false;

            try
            {
                SqlParameter CartId = new SqlParameter("@CartId", System.Data.SqlDbType.Int)
                {
                    Value = model.CartId.HasValue ? model.CartId.Value : 0
                };
                SqlParameter StoreId = new SqlParameter("@StoreId", System.Data.SqlDbType.Int)
                {
                    Value = model.StoreId
                };
                SqlParameter ServiceId = new SqlParameter("@ServiceId", System.Data.SqlDbType.Int)
                {
                    Value = model.ServiceId
                };
                SqlParameter Quantity = new SqlParameter("@Quantity", System.Data.SqlDbType.Decimal)
                {
                    Value = model.Quantity ?? 0
                };
                SqlParameter IsCartRemoved = new SqlParameter("@IsCartRemoved", System.Data.SqlDbType.Bit)
                {
                    Value = model.IsCartRemoved
                };
                SqlParameter AddressId = new SqlParameter("@AddressId", System.Data.SqlDbType.Int)
                {
                    Value = model.AddressId
                };
                SqlParameter UserId = new SqlParameter("@UserId", System.Data.SqlDbType.Int)
                {
                    Value = userId
                };
                var result = _context.ExecuteStoreProcedure("dbo.[usp_AddServiceCart]", CartId, StoreId, ServiceId, Quantity, IsCartRemoved, AddressId, UserId);
                if (result.Tables.Count > 0 && result.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow row in result.Tables[0].Rows)
                    {
                        if (((row["ErrorMessage"] != DBNull.Value) ? Convert.ToString(row["ErrorMessage"]) : string.Empty) == "1")
                        {
                            iSFromDiffrentService = true;
                        }
                    }
                }
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), iSFromDiffrentService));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
            }
            return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), false));
        }
        public async Task <IActionResult> AddServiceCart([FromForm] AddServiceCartRequestViewModel model)
        {
            int?userId    = 0;
            var userStrId = this.User.FindFirstValue(ClaimTypes.Name);

            if (!string.IsNullOrWhiteSpace(userStrId))
            {
                userId = Convert.ToInt32(userStrId);
            }

            var response = new SingleResponse <CartCountResponseViewModel>();

            try
            {
                var result = (await _unit.ICart.AddToServiceCartAsync(model, userId: userId.Value)).UserObject;
                if (result)
                {
                    response.Data          = null;
                    response.Message       = "Cart from different service";
                    response.Status        = true;
                    response.ErrorTypeCode = (int)ErrorMessage.CartRemoverd;
                    return(response.ToHttpResponse());
                }
                else
                {
                    var dataResult = (await _unit.ICart.CartCountAndPrice(userId: userId.Value));
                    response.Data    = dataResult.HasSuccess ? dataResult.UserObject : null;
                    response.Message = "Cart added";
                    response.Status  = true;
                    return(response.ToHttpResponse());
                }
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = "There was an internal error, please contact to technical support.";
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
            }
            return(response.ToHttpResponse());
        }